Page 1 of 1

Posted: Mon Jul 08, 2002 7:02 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.

If I define an up and downarrow keyboard shortcut, can I limit the detection to sepcific gadgets? (Since keyboardshortcuts are eventmenuid() events)

AddKeyboardShortcut(0, #PB_Shortcut_Up, 500) ; make the shortcuts
AddKeyboardShortcut(0, #PB_Shortcut_Down, 501)

; events section -------------------------------------------------
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #CategoryTree ; This is my Tree Gadget
If EventMenuID() = 500
; Do some stuff
EndIF
EndSelect
EndIf
;-----------------------------------------------------------------

Can events be mixed like this to localise detection of these sorts of keyboardshortucts to specific gadgets?

Fangles

Posted: Mon Jul 08, 2002 7:18 am
by BackupUser
Restored from previous forum. Originally posted by fred.

This willn't run as a ShotCut returns a menu event, so EventID = #PB_Event_Menu.
You have to do:

If EventID = #PB_Event_Gadget
....
ElseIf EventID = #PB_Event_Menu ; Menu shortcut

If EventMenuID() = 500 ; You got it !
EndIf
EndIf



Fred - AlphaSND

Posted: Mon Jul 08, 2002 8:10 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
This willn't run as a ShotCut returns a menu event, so EventID = #PB_Event_Menu.
You have to do:

If EventID = #PB_Event_Gadget
....
ElseIf EventID = #PB_Event_Menu ; Menu shortcut

If EventMenuID() = 500 ; You got it !
EndIf
EndIf

Fred - AlphaSND
I understand that but I want to detect specifically if Up/down was pressed in TreeGadget or Up/Down was pressed specifically in ListIconGadget.

So, how do I do that?

Fangles

Posted: Mon Jul 08, 2002 8:49 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Code: Select all

If EventMenuID() = 500 ; You got it !
         x = GetFocus_()
         Select x
           Case hTreeView ; Handle of TreeView
                ; [...]
           Case hListView ; Handle of Listview
                ; [...]
         EndSelect
EndIf
Try this...

cya,
...Danilo

(registered PureBasic user)

Posted: Mon Jul 08, 2002 9:32 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.

Code: Select all

If EventMenuID() = 500 ; You got it !
         x = GetFocus_()
         Select x
           Case hTreeView ; Handle of TreeView
                ; [...]
           Case hListView ; Handle of Listview
                ; [...]
         EndSelect
EndIf
Try this...

cya,
...Danilo

(registered PureBasic user)
Thanks Danilo, that was a great lesson in thinking laterally and will come in useful for other newbies like myself (grin). I've adapted your code like this and it works wonderfully well. Thanks again.

Code: Select all

  If EventID = #PB_EventMenu
    Select EventMenuID()
      Case #F1Code
        Gosub Help_Wanted
      Case #F2Code
        Gosub Find_First
      Case #F3Code
        If First_Match  0
          Gosub Find_Next
        EndIf
      Case #DelCode
        Gosub Delete_Record
      Case #UpCode
        If GetFocus_() And TreeBox
          SetGadgetState(#CategoryTree, GetGadgetState(#CategoryTree) - 1)
          Gosub Display_Categories
        EndIf
      Case #DownCode
        If GetFocus_() And TreeBox (TreeBox is my TreeGadget handle)
          SetGadgetState(#CategoryTree, GetGadgetState(#CategoryTree) + 1)
          Gosub Display_Categories
        EndIf
    EndSelect
  EndIf
Thanks a lot once again

Fangles

Posted: Mon Jul 08, 2002 2:08 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Just use GadgetID() to get the handle of the Gadget easely..

Fred - AlphaSND

Posted: Mon Jul 08, 2002 2:14 pm
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
Just use GadgetID() to get the handle of the Gadget easely..

Fred - AlphaSND
I usually do but decided not to change the way I did all my code for now. I had all the handles in place for API calls that I am slowly replacing with PB code for portability to Unix. Not many to go thank goodness.

Fangles