SDI Example with Window Key Navigation

Share your advanced PureBasic knowledge/code with the community.
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: SDI Example with Window Key Navigation

Post by Frarth »

TomS wrote:The Code from the first post looks like it works on my Win7 32bit (at least it shows the gadgets).
Escape and Enter close the window, Arrowkeys only work in the ComboBox, not with RadioButtons.
Furthermore after clicking any RadioButton, its text changes into "€" (or whatever I type into the Curreny StringGadget), but don't change after another click, regardless of what's in the Currency Gadget.
Do you see focus rings on radio and push buttons? If so, you should be able to see those buttons shift focus with the left and right arrow keys.

The text change happens here as well, so I'll have a look into that. Thanks for the reply!
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: SDI Example with Window Key Navigation

Post by Frarth »

OK, I have found the problem of the text change. Paste this code in the procedure Notation_EventGadget:

Code: Select all

Select Gadget
    Case #Notation_Button_OK
      If Notation_Button_OK()
        ProcedureReturn #True
      EndIf
    Case #Notation_Button_Cancel
      ProcedureReturn #True
    Default
      If Event = #PB_Shortcut_Return
        If Notation_Button_OK()
          ProcedureReturn #True
        EndIf
      ElseIf Gadget = #Notation_String_CurrencySign
        LimitStringGadget(Gadget, #Notation_CurrencySign_Size)
      EndIf
  EndSelect
I have also updated the code in the first post.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: SDI Example with Window Key Navigation

Post by Frarth »

Another interesting fact: If a PB program (with a dialog opened) has the focus, and you start another program (say Windows Explorer), before losing focus GetActiveGadget returns -1. A good thing I believe, but I had to adjust the code in the above example a bit to avoid a "Gadget not initialized" error. Code above updated... :D
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SDI Example with Window Key Navigation

Post by Kwai chang caine »

ts-soft wrote:No changes. Only a question sign in the white small quader.
greetings - thomas
I have testing the first code, and i'm like TsSoft.
My dream it's a day to be like TsSoft.....but for this time....it's not a real pleasure :lol: :lol:
ImageThe happiness is a road...
Not a destination
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: SDI Example with Window Key Navigation

Post by TomS »

Frarth wrote:Do you see focus rings on radio and push buttons? If so, you should be able to see those buttons shift focus with the left and right arrow keys.

The text change happens here as well, so I'll have a look into that. Thanks for the reply!
No, I don't see focus rings, but selecting with arrow keys and space works.
It was a misunderstanding.
I thought the arrow keys select another option, rather than just putting the focus on it.
But since there are no focus indicators, it appears as if it's not working.

A focus rectangle appears when using SetActiveGadget() (but works only kinda randomly...)
Then I can switch to the next/previous option via Tab / Shift+Tab.
With Space I can select this option. (This is not possible without the focus rectangle).
The focus rectangle is still there, but Tab doesnn't move it.
Seems like another great idea from microsoft to make the UI "easier" to understand (whatever...)

Text change issue is now fixed. Good!
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: SDI Example with Window Key Navigation

Post by Frarth »

TomS wrote:
Frarth wrote:Do you see focus rings on radio and push buttons? If so, you should be able to see those buttons shift focus with the left and right arrow keys.

The text change happens here as well, so I'll have a look into that. Thanks for the reply!
No, I don't see focus rings, but selecting with arrow keys and space works.
It was a misunderstanding.
I thought the arrow keys select another option, rather than just putting the focus on it.
But since there are no focus indicators, it appears as if it's not working.

A focus rectangle appears when using SetActiveGadget() (but works only kinda randomly...)
Then I can switch to the next/previous option via Tab / Shift+Tab.
With Space I can select this option. (This is not possible without the focus rectangle).
The focus rectangle is still there, but Tab doesnn't move it.
Seems like another great idea from microsoft to make the UI "easier" to understand (whatever...)

Text change issue is now fixed. Good!
I had the same problem; no focus rings. But that is a Windows issue. Go to -> Display Properties -> Appearance -> Effects. Uncheck "Hide underlined letters for keyboard navigation until I press the Alt key".

It worked for me. Btw, I do use SetActiveGadget in the example above.

- Tab is not supposed to move the focus ring within a group of radio buttons.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
Post Reply