DoubleClick and MouseWheel...weird behavior in listBoxes! **SOLVED**

Started by Knox, Wed 03/11/2010 10:36:15

Previous topic - Next topic

Knox

Hi,

This one is truly pissing me off! I really dont know why this is giving me weird results:

Ive got a GUI with a listbox that when you double click on an item, it executes a script (you send a radio message). Everything works fine if I dont select an item in that list first, pause, then double click...it works properly only if I use the double-click on the items within the list.

Example-->


Lets say I double-click on "Code-10", cool, it works...the main player radio's dispatch Code-10...BUT, if I select, say, "Code-9" with single click first, then double-click on "Code-10", Code-9 will be sent since there isnt enough time to switch the text to Code-10 (Im guessing?)

Here are the scripts Im using...Im not sure why its not behaving properly.
Code: ags

void doubleClick(eDoubleClickSpeed eSpeed)
{
  ViewFrame *frame0 = Game.GetViewFrame(VWAIT_FAKE, 0, 0);
  if (frame0.Graphic != 2061) frame0.Graphic = 2061;
  mouse.ChangeModeView(eModeWait, 54); //fake "Pointer-Wait" view...(waitMouseKey shows Wait View)
  mouse.ChangeModeGraphic(eModeWait, 2061);
  
  int iDoubleClick;
  int dc;
  if (eSpeed == eSlowClick) dc = 15;
  else if (eSpeed == eMediumClick) dc = 12;
  else if (eSpeed == eFastClick) dc = 9;
  
  iDoubleClick = (WaitMouseKey(dc) * mouse.IsButtonDown(eMouseLeft));
  if (iDoubleClick)
  {
    mouse.ChangeModeView(eModeWait, 14); //restore Default Wait view
    mouse.ChangeModeGraphic(eModeWait, 297);    
    //DisplayACL("Double click!");
    iExecuteDC = 1;
  }
  else iExecuteDC = 0; 
}


Code: ags

void on_event (EventType event, int data)
{ 
  overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  if (event == eEventGUIMouseDown && overGuiControl == lstRadioCode) doubleClick(eMediumClick);
}

Code: ags

//in rep_Exec
  ...else if (gRadio.Visible)
  { 
    if (overGuiControl == null || lstRadioCode.SelectedIndex == -1)
    {
      if (sldRadio_Channel.HandleGraphic != 1433) sldRadio_Channel.HandleGraphic = 1433; //reset
      else if (sldRadio_Frequency.HandleGraphic != 1421) sldRadio_Frequency.HandleGraphic = 1421; //reset
      clearLBL(lblRadioHotspot);
    }
    else 
    {  
      if (overGuiControl == lstRadioCode)
      {
        if (iExecuteDC == 1)
        {
          if (bReady == true)
          {
            btnRadio_Send_OnClick(btnRadio_Send, eMouseLeft);
            iExecuteDC = 0;
            bReady = false;
            return;
          }
        }
      } 


Code: ags

function lstRadioCode_OnSelectionChange(GUIControl *control)
{
  clearTXT(txtRadio_CodeInput); //first clear whats in the LCD
  String selectedItemText = lstRadioCode.Items[lstRadioCode.SelectedIndex];
  txtRadio_CodeInput.Text = selectedItemText;
  bReady = true;
}

I think it has something to do with iExecuteDC = 0 (if double-click is false)...cause thats when it seems it screws things up.
--All that is necessary for evil to triumph is for good men to do nothing.

Knox

Man after (serious) a few days debugging, I solved it!

I needed to add this in my rep_exec:

Code: ags

      else if (overGuiControl == lstRadioCode)
      {
        if (iExecuteDC == 1)
        {
          if (bReady == true)
          {
            btnRadio_Send_OnClick(btnRadio_Send, eMouseLeft);
            iExecuteDC = 0;
            bReady = false;
            return;
          }
        }
        else if (iExecuteDC == 0)
        {
          if (bReady == true)
          {
            //btnRadio_Send_OnClick(btnRadio_Send, eMouseLeft);
            iExecuteDC = 0;
            bReady = false;
            return;
          }          
        }


Maybe this post will help someone with a similar prob :P
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk