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-->
(http://img600.imageshack.us/img600/8776/whynoworkey.png)
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.
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;
}
void on_event (EventType event, int data)
{
overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (event == eEventGUIMouseDown && overGuiControl == lstRadioCode) doubleClick(eMediumClick);
}
//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;
}
}
}
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.
Man after (serious) a few days debugging, I solved it!
I needed to add this in my rep_exec:
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