It is currently Wed Nov 25, 2020 2:46 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Focus rectangle initially not shown (modern theme support)
PostPosted: Sun Nov 08, 2020 12:26 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Hi,

I tested with PB 5.72 LTS and 5.73 beta 3 on Windows 10.
The problem only exists here when the compiler option
Quote:
[v] Enable modern theme support (for Windows XP and above)
is checked.

Code:
OpenWindow(0, 100, 100, 150, 150, "Focus test")
ButtonGadget(0, 30,  20, 80, 30, "Button 0")
ButtonGadget(1, 30,  60, 80, 30, "Button 1")
ButtonGadget(2, 30, 100, 80, 30, "Button 2")
SetActiveGadget(0)

Repeat
   event = WaitWindowEvent()
   Select event
      Case #PB_Event_Gadget
         Debug "Button #" + GetActiveGadget()
   EndSelect     
Until event = #PB_Event_CloseWindow

After pressing the TAB key (repeatedly), I see the focus rectangle on Button 1 (Button 2 etc.). OK.

But since it reads in the code
Code:
SetActiveGadget(0)
the focus rectangle should be on Button 0 right after the program start. However, it is not visible at all.

Is this a bug?

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Sun Nov 08, 2020 2:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 769
Location: Linz, Austria
https://www.purebasic.fr/english/viewtopic.php?p=315265#p315265

_________________
Et cetera is my worst enemy


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Sun Nov 08, 2020 7:49 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Dooh! This old issue?
I almost had forgotten about that. Thanks for reminding me!
This bug was marked [Done] in 2009, but was only partially fixed or reoccurred partially. :shock:

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Mon Nov 09, 2020 11:36 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14178
Location: France
It's not a bug, the focus rectangle should appears only after use TAB at least once. You can check this behaviour in the Print Preview panel of Notepad for example.


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Mon Nov 09, 2020 11:48 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Thanks for looking into this issue, Fred.
Fred wrote:
It's not a bug, the focus rectangle should appears only after use TAB at least once.
Sorry, that doesn't make sense to me.
The focus rectangle should show which gadget the focus has, no?
Immediately after running the above code snippet, Button0 has the focus.
This can be demonstrated by pressing [Space] right after the start of the program.
And since in that situation Button0 has the focus, the focus rectangle should be visible on Button0.
This is pure logic (no pun intended), and this is required for flawless usability,
and this is independent from what Notepad does do or does not do.

And when Modern Theme Support is switched OFF, the focus rectangle IS shown on Button0!
So are you saying that there is a bug without Modern Theme Support?

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Mon Nov 09, 2020 12:13 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14178
Location: France
It's not a bug, it's a guide line for modern theme, which is to hide the focus rectangle unless keyboard is involved (may be for touch screen etc). It's the default behaviour of Windows app, so we follow it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Focus rectangle initially not shown (modern theme suppor
PostPosted: Tue Nov 17, 2020 8:43 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Fred wrote:
It's not a bug, the focus rectangle should appears only after use TAB at least once.

I searched on the internet, and found this:
The default state for a window is to show all indicators. But as a special trick, the dialog manager will send a WM_UPDATE­UI­STATE message with UIS_INITIALIZE after the dialog has been initialized, which turns off the indicators if the last input event was a mouse event. This is its way of inferring whether the dialog box was triggered by a mouse or keyboard action and setting the initial indicators accordingly. (Note that if the user checked Underline keyboard shortcuts and access keys, then the dialog manager leaves the indicators enabled regardless of the last input event.)

That special WM_UPDATE­UI­STATE message is what gives dialog boxes the extra special feature of hiding the keyboard accelerators until you use the keyboard.

But notice that only the dialog manager does this. If you want this behavior in your own non-dialog windows, you will need to send the message yourself.

No, I don't want this behavior in my own non-dialog windows, so there is no need for PB to send this message. :-)

Fred wrote:
You can check this behaviour in the Print Preview panel of Notepad for example.

On my system (Windows 10), it depends. The behaviour is as Raymond Chen wrote: When I open that dialog by using the mouse, no focus indicator is shown. But when I open that dialog by using the keyboard, then a focus indicator is shown on the topmost combobox, immediately when the dialog is shown! (And I never pressed the TAB key in that situation.)

I also found this:
When designing a keyboard UI, use the following guidelines for input focus:
  • Make the input focus obvious.
    Make input focus visually distinguishable in a way that is obvious, intuitive, and easily seen.
    [...]
  • Display an input focus indicator.
    Display an input focus indicator when the window first opens or becomes active.
    For exceptions to this guideline, see Input Focus Exceptions.

So yes, there are exceptions, but the rule is: "Display an input focus indicator when the window first opens or becomes active.".

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye