|
-
Can you detect when the cursor turns to a hand?
Hi!
I have problem I would like to solve.
I would like a function to run when a user clicks anywhere on stage. But this function should not run when the click is on buttons & on url:s inside a dynamic html-formated textfield. How can I detect this? I do realise that the cursor turns to a hand when you hoover over a url inside a textfield & you can set the hand to appear on buttons as well (which i always set it to do). So is there a way in realtime to detect when the cursor is & is not a hand?
I've tried the following:
Code:
btn_mc.buttonMode = true;
stage.addEventListener(MouseEvent.MOUSE_DOWN,down)
function down(E:MouseEvent)
{
if(E.target.useHandCursor != true && E.target == stage)
{
trace("Hello!")
}
}
On the
Code:
E.target.useHandCursor
- part I've also tried
Code:
E.target.buttonMode
but I get 1069 errors.
Any ideas anyone?
Best, Niklas
-
I'm not sure about dynamic text fields, but generally the way you do this is to stop event bubbling, which stops the event from reaching the stage. You do this with eventName.stopPropagation()
Here's a simplified example of what I did recently:
Code:
stage.addEventListener(MouseEvent.CLICK, clickStage);
myBtn.addEventListener(MouseEvent.CLICK, clickBtn);
function clickStage(e){
trace("clicked stage");
}
function clickBtn(e){
e.stopPropagation();
trace("clicked button");
}
-
Hey!
Thanks for your reply.
I will see if I can find a way to detect URL:s in the textfield.
I don't know much about event bubbling so I will take a look at that to - you learn something everyday. 
Niklas
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|