Re: Dialog Question

Discussions related to mouse, keyboard, fonts and Graphical User Interface
Hated Moron

Re: Dialog Question

Post by Hated Moron »

On 13/09/2023 01:42, Daniel Bingamon wrote (cross-posted from the Discussion Group):
I'd like to intercept a doubleclick event... What I would like to do is when the user double-clicks the listbox item it does the equivalent of the transfer button that moves the item to another list.
By design the BBCSDL dialogue manager treats double-clicking in a listbox the same as pressing OK, i.e. it returns a 1 from FN_showdialog(). This is commonly the required behaviour.

If you want double-clicking to do something different you must firstly make sure you can uniquely detect that condition (so for example allocate a code other than 1 to the OK button, if you have one) and then take the appropriate action when you see a 1 returned, as follows:

Code: Select all

      REPEAT
        result% = FN_showdialog(dlg%, &80000000, &80000000)
        IF result% = 1 THEN
          REM Perform the double-click action
        ENDIF
      UNTIL result% <> 1
The only caveat is that since this involves calling FN_showdialog() again, if the user has moved the dialogue box since it was first opened it will be moved back to its initial position. This could be disconcerting so if you want to avoid it you can do:

Code: Select all

      X% = &FFFFFFFF80000000 : Y% = &FFFFFFFF80000000
      REPEAT
        result% = FN_showdialog(dlg%, X%, Y%)
        PROC_getdlgrect(dlg%, X%, Y%, W%, H%)
        IF result% = 1 THEN
          REM Perform the double-click action
        ENDIF
      UNTIL result% <> 1
This re-shows the dialogue box in whatever position the user has moved it to.