CalendarGadget keyboard focus

Just starting out? Need help? Post your questions and find answers here.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

CalendarGadget keyboard focus

Post by Dude »

When another gadget has the focus, and you click a date on a CalendarGadget, you can't initially move around the dates with the arrow keys.

But if you Tab away from the CalendarGadget and then Tab back to it, you CAN move around the dates with the arrow keys, as expected.

So is there a way to give the keyboard focus to the CalendarGadget when you click a date with the mouse? Or is this a bug?

Code: Select all

If OpenWindow(0,200,200,250,250,"CalendarGadget",#PB_Window_SystemMenu)
  CalendarGadget(0,10,10,240,180)
  ButtonGadget(1,10,200,230,40,"Click a date and use arrow keys")
  SetActiveGadget(1)
  Repeat
    ev=WaitWindowEvent()
  Until ev=#PB_Event_CloseWindow
EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: CalendarGadget keyboard focus

Post by RASHAD »

No bug ,it's by design
At least for Windows API :wink:

Workaround

Code: Select all

If OpenWindow(0,200,200,250,250,"CalendarGadget",#PB_Window_SystemMenu)
  CalendarGadget(0,10,10,240,180)
  ButtonGadget(1,10,200,230,40,"Click a date and use arrow keys")
  SetActiveGadget(1)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Gadget
        SetActiveGadget(EventGadget())
        Select EventGadget()
          Case 1
            Debug "OK"
        EndSelect
    EndSelect
  Until Quit = 1        
EndIf
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: CalendarGadget keyboard focus

Post by Dude »

Code: Select all

SetActiveGadget(EventGadget())
Good old Windows... we have to manually give the focus to the gadget we just focussed with a mouse click. :twisted:

Thanks Rashad. You truly are a fountain of information. I'll be devastated if you ever leave here. :)
Post Reply