Page 1 of 1

Autohide Stack based on mouse coordinates?

Posted: Tue Jun 05, 2007 4:16 am
by Garrett
Greetings,

Trying to autohide a stack that is merely a menubar of selected tools for a user to use. I'm trying to autohide it when the mouse goes below the bar, if a menu is not presently open.

right now, I'm using "on mouseLeave" to detect when the mouse has left and no menu is open. Then I'm using "send subMouseLoop to me in 1 milliseconds" to test if the mouse location. If it's < 1, then the user has the mouse at the top of the screen. but I'm running into all sorts of problems and I'm not sure why or what to do to resolve them at the moment.

Code: Select all

on openStack
  send subMouseLoop to me in 1 milliseconds
end openStack

Code: Select all

on mouseLeave
  if field "SettingsAutoHide" is "yes" and field "TestField" is not "Mouse OUT" then
    put "Mouse OUT" into field "TestField"
    set the top of me to -22
  end if
  send subMouseLoop to me in 1 milliseconds
end mouseLeave

Code: Select all

on subMouseLoop
  send subMouseLoop to me in 1 milliseconds
  if field "SettingsAutoHide" is "yes" then
    put the mouseLoc into field "DateTimeField"
    --set the itemdel to ","
    put item 2 of the mouseLoc into varMouseV
    if varMouseV < 1 and field "TestField" is "Mouse OUT" then
      set the top of me to 0
      put "Mouse in" into field "TestField"
    end if
  end if
end subMouseLoop
Do I need to also put "send subMouseLoop to me in 1 milliseconds" into every event handler in order to get back to my mouse checking loop? Or am I creating a horrible mess here? Is there a better way to setup a global loop of some sort for what I'm in need of?

Thank in advance,
-Garrett

Posted: Tue Jun 05, 2007 10:00 pm
by xApple
Instead of storing your variables in fields like "if field "SettingsAutoHide" is "yes"" you should use global variables.

Having "send subMouseLoop to me in 1 milliseconds" in the mouseLeave handler will start several loops at the same time, I wouldn't do this.

And you might want to put the "send subMouseLoop to me in 1 milliseconds" at the end of the subMouseLoop handler instead of the first line.

"set the itemdel to ","" is usless since at the start of a new handler it is always the case.

Posted: Wed Jun 06, 2007 9:20 pm
by Garrett
xApple wrote:Instead of storing your variables in fields like "if field "SettingsAutoHide" is "yes"" you should use global variables.

Yes, I know, it's force of habit ;-)
xApple wrote:Having "send subMouseLoop to me in 1 milliseconds" in the mouseLeave handler will start several loops at the same time, I wouldn't do this.

K, dump that from the mouseLeave, thanks :-)
xApple wrote:And you might want to put the "send subMouseLoop to me in 1 milliseconds" at the end of the subMouseLoop handler instead of the first line.

k, thanks :-)
xApple wrote:"set the itemdel to ","" is usless since at the start of a new handler it is always the case.
Yup, I had already commented it out. Thanks. :-)

I also thought the 1 millisec was too much and have since pumped that up to 100 millisec.

Thanks a bunch for the help and info :-)
-Garrett

Posted: Wed Jun 06, 2007 10:53 pm
by xApple
No prob !
Is it working well now ?
There is a thread just here that might interest you. Though not exactly related, we do discuss how to maintain a looping handler while letting other handlers start...

http://forums.runrev.com/phpBB2/viewtopic.php?t=802

Good day !

Posted: Thu Jun 07, 2007 9:40 am
by Garrett
Got carried away playing a game online since my reply.... I'll try it for sure in the morning here. :-) And I'll check that thread too.

Again, thanks a bunch. :-)
-Garrett

Posted: Thu Jun 07, 2007 11:14 pm
by Garrett
Yes, that seems to have done the job. :-)

Thanks a bunch,
-Garrett