Page 1 of 1
RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 5:10 am
by ozzie
If I use
RemoveKeyboardShortcut with
#PB_Shortcut_All then this prevents the tab key from tabbing between fields.
For example, in this program you cannot tab through the fields unless you comment out 'RemoveKeyboardShortcut(0, #PB_Shortcut_All)':
Code: Select all
If OpenWindow(0, 0, 0, 305, 240, "Shortcut Tab Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(1,100,30,80,20,"1")
StringGadget(2,100,60,80,20,"2")
StringGadget(3,100,90,80,20,"3")
SetActiveGadget(1)
RemoveKeyboardShortcut(0, #PB_Shortcut_All)
Repeat
giWindowEvent = WaitWindowEvent()
Until giWindowEvent = #PB_Event_CloseWindow
EndIf
How can I reinstate normal tab behavior after using RemoveKeyboardShortcut(0, #PB_Shortcut_All)? I guess I could maintain an array of shortcuts I've added by AddKeyboardShortcut() and step through that array and remove each shortcut individually, but if there's an easier way I'd rather use it!
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 9:03 am
by RASHAD
Use next snippet instead
Code: Select all
If OpenWindow(0, 0, 0, 305, 240, "Shortcut Tab Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(1,100,30,80,20,"1")
StringGadget(2,100,60,80,20,"2")
StringGadget(3,100,90,80,20,"3")
ButtonGadget(4,10,120,60,20,"TEST")
SetActiveGadget(1)
AddKeyboardShortcut(0,#PB_Shortcut_A,10)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case 10
Debug "A"
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 4
For i = 0 To 64000
If i = 9
i + 1
EndIf
RemoveKeyboardShortcut(0,i)
Next
EndSelect
EndSelect
Until Quit = 1
EndIf
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 9:33 am
by netmaestro
If RemoveKeyboardShortcut with #PB_All is destroying the keyboard accelerators that were in place before any AddKeyboardShortcut commands were executed, then that's a bug in PureBasic. RemoveKeyboardShortcut with #PB_All should restore the accelerator table to the condition it was in before any AddKeyboardShortcut only, no more than that. I recommend reporting this as a bug. Let the dev team worry about skipping over the tab key.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 9:50 am
by ozzie
I thought it might be a bug but wasn't sure. I've now re-posted this in the Bugs forum - so this current topic may be deleted.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 10:20 am
by PB Fanatic
Not a bug for the reason I pointed out in your bug report.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 11:09 pm
by ozzie
OK - I've just noticed that under AddKeyboardShortcut() in the Help that it states "By default, a window already has the #PB_Shortcut_Tab and #PB_Shortcut_Tab|#PB_Shortcut_Shift shortcuts to handle tab and shift-tab correctly trough the gadgets." The simplest work-around seems to be what RASHAD suggested, using a loop that removes all keyboard shortcuts in the range 0 - 64000 except for #PB_Shortcut_Tab.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 11:45 pm
by netmaestro
Removing shortcuts with #PB_All shouldn't change that - it should put the accelerator table back the way it was before the coder used any AddKeyboardShortcut.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Thu Jan 01, 2015 11:55 pm
by ozzie
I agree - or alternatively there should be another option to remove only the shortcuts added using the AddKeyboardShortcut() function. Maybe I'll add a Feature Request for this if the PB team decide the present behavior is not a bug.
Re: RemoveKeyboardShortcut with #PB_Shortcut_All kills tab
Posted: Fri Jan 02, 2015 2:49 am
by PB Fanatic
netmaestro wrote:Removing shortcuts with #PB_All shouldn't change that - it should put the accelerator table back the way it was before the coder used any AddKeyboardShortcut.
We need a new flag then, so instead of #PB_Shortcut_
All, we can use #PB_Shortcut_
Revert. All means all, IMO, and there may be reasons for a user to purposely remove Tab shortcuts as part of their decision to remove all.