Double Click on Button

Started by fitbo, Sat 12/04/2014 17:57:34

Previous topic - Next topic

fitbo

Hi everyone,

i'm using a double click code which is working just fine, the only time it doesn't work is when i double click a gui button.
If i double click the gui it works but not the button on the gui.
I tried with different gui and buttons but always the same result.

Here is the code for the button on the gui which doesn't work:

Code: ags

function btnPocketPC_OnDoubleClick(GUIControl *control, MouseButton button)
{
  gPocketPC.Visible = true;
}
function btnPocketPC_OnClick(GUIControl *control, MouseButton button)
{
// Double click
  if (mouseTimer>0 && mouseTimer<14 && mouse.IsButtonDown(eMouseLeft))
  {
     btnPocketPC_OnDoubleClick(control,  button);
      return;
  }
  mouseTimer=0;


And here is the code for the gui where the button is on, which works:

Code: ags

function gIcon_OnDoubleClick(GUI *theGui, MouseButton button)
{
  gPocketPC.Visible = true;
}

function gIcon_OnClick(GUI *theGui, MouseButton button)
{
 // Double click
  if (mouseTimer>0 && mouseTimer<14 && mouse.IsButtonDown(eMouseLeft))
  {
      gIcon_OnDoubleClick(theGui,  button);
      return;
  }

  mouseTimer=0;
}


I looked everywhere but i don't seem to find a solution.
Is there any other way to double click a button?
Any help is appreciated:)

Dualnames

If the gui is paused when shown, and you increase the mousetimer variable somewhere where when the gui is open the variable stays to 0 or to whatever value it had, your code will never get executed.

Try running the code which doesn't work the following way, tell me the output of the display function.

Code: ags

function btnPocketPC_OnDoubleClick(GUIControl *control, MouseButton button)
{
  gPocketPC.Visible = true;
}
function btnPocketPC_OnClick(GUIControl *control, MouseButton button)
{
// Double click
  Display("%d", mouseTimer); //for testing purposes.
  if (mouseTimer>0 && mouseTimer<14 && button == eMouseLeft)
  {
     btnPocketPC_OnDoubleClick(control,  button);
      return;
  }
  mouseTimer=0;



Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

fitbo

#2
Thanks for your answer and I apologize for my late reply.

First of all, the code that I posted works, but only half of the time and only because I added your Display function to my code.
Here are the results:

If I click the first time on the button the display function shows 1000 (thats the value of the mouseTimer, declared in the Global Script).
After that the value keeps changing, depending on how fast the mouse get clicked.
Although I have to say, the numbers that are getting displayed seem a little random, because sometimes the code works (the gui gets displayed), and sometimes it doesn't work, even though I click as fast as the other times or even faster.
If I'm trying to click as fast as possible the value varies from 10 to 25 approx.
Hope my answer is clear enough for you.

Thanks in advance!

SMF spam blocked by CleanTalk