Home > php教程 > PHP开发 > How to determine whether to click outside the component in Flex

How to determine whether to click outside the component in Flex

高洛峰
Release: 2016-12-27 17:26:09
Original
1103 people have browsed it

Yesterday when I was doing Flex development, I encountered such an operation. I have encountered it before. The method at that time was not very good. Today I encountered a similar problem. Let’s take a look at a picture first!

How to determine whether to click outside the component in Flex

This is what the system interface looks like. The current situation is that the red area is a window, page, or component. You need to click outside this component to hide it. The previous idea of ​​this component was very simple, which was to judge by coordinates, but now the structure of the red area is more complicated, so I don’t know how to solve it. Later, I met a netizen and gave me a piece of code. I think Not bad, I think it’s a technical thing! So share this:

First, listen to the click event in the black area, and then judge it through the contains method in the handler of the click event. The code is as follows:

public functionclickHandler(event:MouseEvent):void 
{ 
if(!红色区域.contains(event.target asDisplayObject) && !绿色区域.contains(event.target as DisplayObject)) 
{ 
红色区域.visible = false; 
} 
}
Copy after login

This code, I think is a better solution. The initial idea was to judge by coordinates, and then another idea came up, which was to listen for the mouse to leave in the red area and listen for the click event in the leaving handler, but this method does not seem to work. So I asked netizens and found out about this method.

There is another little episode here: My QQ avatar belongs to Luffy. Coincidentally, the person who helped me solve the problem was a netizen with Zoro's avatar. After solving the problem, he even called me. Captain, it’s very interesting!

For more related articles on how to determine whether to click outside a component in Flex, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template