entire screen responds to mouseDown | SOLVED |

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

entire screen responds to mouseDown | SOLVED |

Post by Johan_VH » Tue Jul 08, 2014 4:43 pm

Just when I thaugt everything was going smoothly... I clicked at random on the screen, and it responded to the mouseDown...

I have 3 buttons that behave like a background on all my cards. These buttons are groups of a button, a text layer and a graphic layer.

I have this code placed on each button, because I cannot seem to get it to work if I put it on a card script.

Code: Select all

on mouseDown 
   local thisGroup
   put the short name of  group me into thisGroup
   put (thisGroup)
     switch (thisGroup)
        case "next_btn"  
           set the icon of button ("navigation_btn") of group ("next_btn") to "button_zwart.png"
           go to the next card of  stack "registration"
          break
      case "back_btn"
         set the icon of button ("navigation_btn") of group ("back_btn") to "button_zwart.png"
         break
      case "logout_btn"
         set the icon of button ("navigation_btn") of group ("logout_btn") to "button_zwart.png"
         break
   end switch

end mouseDown

on mouseLeave
   call "navWhite" of card "taal" of stack "registration"
end mouseLeave
It works, each button does as it should, so it gets the name of the group they belong to. I cannot get the name of the group if I put it in a card script for some reason. That doesn't really bother me right now, it's only 3 buttons, but why oh why does the rest of the screen execute the mouseDown script?? It takes the script of the group in the uppermost layer by the way.

Ideally, I would like to have the entire mouse Event handling on a stack script, that would seem the most logically to me, but as stated above, I can't get the name of the group, just of the separate elements of which the group consists... (I tried 'target')

Anyone...?

Johan
Last edited by Johan_VH on Wed Jul 09, 2014 9:55 am, edited 1 time in total.

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: entire screen responds to mouseDown

Post by Johan_VH » Tue Jul 08, 2014 4:51 pm

Ok, I just figured out that turning off "behave like a background" prevents the entire screen responding to the mouseEvent, so I guess I'll be manually putting the buttons in on each card. But is it really not possible to have a stack script handle all of the mouseEvents? I guess it would work if just used regular buttons, but that won't ever be the case for me...

Johan

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: entire screen responds to mouseDown

Post by Klaus » Tue Jul 08, 2014 5:04 pm

Dag Johan,

try this in the card script:

Code: Select all

on mouseDown 
   local thisGroup

   ## Get the name of the GROUP that contains the clicked object (if at all)
   put the short name of the OWNER of the target thisGroup

  ## No need to put parens around a single variable name :-)
   put thisGroup
   switch thisGroup
        case "next_btn"  
           set the icon of button ("navigation_btn") of group ("next_btn") to "button_zwart.png"
           go to the next card of  stack "registration"
          break
      case "back_btn"
         set the icon of button ("navigation_btn") of group ("back_btn") to "button_zwart.png"
         break
      case "logout_btn"
         set the icon of button ("navigation_btn") of group ("logout_btn") to "button_zwart.png"
         break
   end switch

end mouseDown

## Here you should also check the OWNER, if you do not wnat to fire this handler EVERY time the mouse left something.
on mouseLeave
   call "navWhite" of card "taal" of stack "registration"
end mouseLeave
Best

Klaus

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: entire screen responds to mouseDown

Post by Johan_VH » Wed Jul 09, 2014 8:56 am

Thank you Klaus!

Und gratuliere zum Sieg über Brasilien :-)

Johan

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: entire screen responds to mouseDown

Post by Klaus » Wed Jul 09, 2014 11:15 am

Dag Johan,
Johan_VH wrote:Thank you Klaus!
graag gedaan :-)
Johan_VH wrote:Und gratuliere zum Sieg über Brasilien :-)
Was er een oorlog? 8)

Post Reply