MouseYPos GUI issue

Started by Makeout Patrol, Sat 05/07/2008 00:10:46

Previous topic - Next topic

Makeout Patrol

I have an issue with a GUI that has its visibility set to MouseYPos. It shows up and disappears like it's supposed to, but whenever the player hits a mouse button while it's showing, the mouse moves a few pixels down, making the GUI disappear. This wouldn't be a huge issue if it were only used for saving and loading, but it's also used for the inventory, and has a pair of scrolling arrows - whenever the player clicks on them, the window disappears, and though the window has scrolled properly when they move the mouse back, it's a pretty jarring effect and I'd really like to get rid of it. Any suggestions? There is nothing in the script that would be causing this - nothing changes the position of the mouse, and the GUI itself is only referenced once, when it is made visible after the user leaves the main menu.

DoorKnobHandle

#1
I think it's fixed behavior of the MouseYPos-setting for GUIs to make them disappear whenever the mouse has been clicked. So, put short, setting a GUI with clickable arrows etc. to pop up on MouseYPos is not a good idea.

Write your own code for better results (not only to be able to fix that problem, but writing your own routine for stuff like this also drastically increases flexibility - imagine you want the GUI bar to not only appear, but quickly scroll down whenever the mouse is close, it's easy to do with your own function), something like:

Code: ags

// in rep_exec

if ( mouse.y < 20 )
// if mouse is close to top-edge of the screen
{
      // if GUI is not yet visible
      if ( !gBar.Visible )
            gBar.Visible = true;
}
else
// if mouse is not close to top-edge of the screen
{
      // if GUI is not yet hidden
      if ( gBar.Visible )
            gBar.Visible = false;
}


Code not tested, might not work out of the box, but the jist is there. It'll show or hide the GUI depending on your cursor's y-position.

Makeout Patrol

#2
All right, seems simple enough. Thanks.

EDIT: I should have done this a long time ago - it's also fixed a couple of other minor problems.

SMF spam blocked by CleanTalk