How allow user to double click item in Dialog Box.

Started by pguild, May 04, 2019, 01:39:17 AM

Previous topic - Next topic

pguild

I would like the user to be able to double click an item in a listbox within a dialog
instead of having to press OK.  Is there any way to enable that?

JTaylor

If you go to the WIL Help file and under the Search Tab enter "dialog itembox double click" and then select ItemBox Control from the results it will provide the needed information.   

Jim

pguild

Thanks, Jim,  :)
Users don't want to have to click a selection and then press enter. They just want to double click an item and continue.
To make the dialog close, I need to set a return to some positive number in the @deIbDblclick case.  That was not easy to discover. :)


#DefineFunction TimerProc(MyDialogHandle,MyDialogMessage,MyDialogControlID,MyDialogEventInfo,MyDialogChangeInfo)
Switch MyDialogMessage
   Case @deInit
      ; enable 1 second timer events
      DialogProcOptions(MyDialogHandle, @deTimer, 1000)
      DialogProcOptions(MyDialogHandle, @deIbDblclick,1)

      Return (@retdefault)
   Case @detimer
      Clock=DialogControlGet(MyDialogHandle, "VaryText_1", @dcTitle)
      Clock=Clock-1
      If Clock==0 Then Return(2) ; exit, buttonpushed==2
      DialogControlSet(MyDialogHandle, "VaryText_1", @dcTitle, Clock)
      Return(@retDefault)
   Case @deIbDblclick
      pause("Yes","You double clicked!")
          ;RETURN(@retDefault) ;?????????????????????  WRONG
          RETURN(1)

EndSwitch ; MyDialogMessage
Return(@retDefault) ; Do default processing
#EndFunction

;main;
dlg_itembox = strcat("Never talk about mistakes",@TAB,"Seek Clarity",@TAB,"Define Targets for Improvement")
TimerFormat=`WWWDLGED,6.2`

TimerCaption=`Timer Example`
TimerX=078
TimerY=129
TimerWidth=382
TimerHeight=198
TimerNumControls=004
TimerProcedure=`TimerProc`
TimerFont=`DEFAULT`
TimerTextColor=`DEFAULT`
TimerBackground=`DEFAULT,DEFAULT`
TimerConfig=0

Timer001=`013,083,034,014,PUSHBUTTON,"PushButton_1",DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer002=`067,083,034,014,PUSHBUTTON,"PushButton_2",DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer003=`023,015,070,052,VARYTEXT,"VaryText_1",clock,"100",DEFAULT,DEFAULT,@csCenter,"Tahoma|49152|70|34","128|0|0",DEFAULT`
Timer004=`199,019,102,134,ITEMBOX,"ItemBox_1",dlg_itembox,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Timer")
pause("You Picked",dlg_itembox)

RETURN

JTaylor

Try this. 
Jim


Code (winbatch) Select


#DefineSubRoutine TimerProc(MyDialogHandle,MyDialogMessage,MyDialogControlID,MyDialogEventInfo,MyDialogChangeInfo)
  Switch MyDialogMessage
     Case @deInit
        ; enable 1 second timer events
        DialogProcOptions(MyDialogHandle, @deTimer, 1000)
        DialogProcOptions(MyDialogHandle, @deIbDblclick,1)
        Break
     Case @detimer
        Clock=DialogControlGet(MyDialogHandle, "VaryText_1", @dcTitle)
        Clock=Clock-1
        If Clock==0 Then Return(2) ; exit, buttonpushed==2
        DialogControlSet(MyDialogHandle, "VaryText_1", @dcTitle, Clock)
        Break
     Case @deIbDblclick
        dc_value = DialogControlGet(MyDialogHandle,"ItemBox_1",@dcSelect)
        RETURN 99
        Break
  EndSwitch ; MyDialogMessage
  Return @retNoExit
#EndSubRoutine

;main;
dlg_itembox = strcat("Never talk about mistakes",@TAB,"Seek Clarity",@TAB,"Define Targets for Improvement")
TimerFormat=`WWWDLGED,6.2`

TimerCaption=`Timer Example`
TimerX=078
TimerY=129
TimerWidth=382
TimerHeight=198
TimerNumControls=004
TimerProcedure=`TimerProc`
TimerFont=`DEFAULT`
TimerTextColor=`DEFAULT`
TimerBackground=`DEFAULT,DEFAULT`
TimerConfig=0

Timer001=`013,083,034,014,PUSHBUTTON,"PushButton_1",DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer002=`067,083,034,014,PUSHBUTTON,"PushButton_2",DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer003=`023,015,070,052,VARYTEXT,"VaryText_1",clock,"100",DEFAULT,DEFAULT,@csCenter,"Tahoma|49152|70|34","128|0|0",DEFAULT`
Timer004=`199,019,102,134,ITEMBOX,"ItemBox_1",dlg_itembox,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("Timer")

pause("You Double-Clicked...",dc_value)

RETURN

pguild

Hi Jim, thanks for your response.

Yes returning 99 will work, but returning any positive number also works as in my example, where I return 1.

JTaylor

Guess I am misunderstanding???   Does it not continue after double-clicking an item and returning its value as requested?

Jim

td

Quote from: pguild on May 06, 2019, 01:38:31 PM
Thanks, Jim,  :)
Users don't want to have to click a selection and then press enter. They just want to double click an item and continue.
To make the dialog close, I need to set a return to some positive number in the @deIbDblclick case.  That was not easy to discover. :)

The effects of a user-defined dialog callback procedure's return values are documented in the Consolidated WIL Help file.  See:

Home > Windows Interface Language Reference > Things to Know > Dialogs > Dynamic Dialogs
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade