It is currently Wed Sep 18, 2019 7:13 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [solved] Button focus or lack of it
PostPosted: Wed Mar 23, 2016 11:53 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 24, 2011 1:36 pm
Posts: 276
I'm sure there's a simple solution. How do I enable the blue highlighting of buttons (focus) when pressing tab, as happens with other mac apps including the PB editor?

It just works in windows, so I'm a bit confused.

Thanks

Code:
OpenWindow(0, 0, 0, 100, 100, "Test")
ButtonGadget(0, 0, 0, 100, 30, "Test1")
ButtonGadget(1, 0, 35, 100, 30, "Test2")

Repeat
 
Until WaitWindowEvent() = #PB_Event_CloseWindow


Last edited by Julian on Thu Mar 24, 2016 4:10 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 5:56 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3434
Location: Netherlands
See this post
viewtopic.php?p=390031#p390031

_________________
macOS 10.14 Mojave, PB 5.62 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 1:28 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 24, 2011 1:36 pm
Posts: 276
Thanks Wilbert, but there's nothing in that post that turns this feature on. It would seem the the feature shows when a StringGadget (or list) is selected, the tab shows then and cycles through the controls, but it doesnt work when the window is opened and nothing is clicked.

Any ideas?


Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 1:40 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3434
Location: Netherlands
Sorry, I misread your question; thought you were asking how to set the default button (which makes it blue).
From what I read online, a NSButton normally can't have keyboard focus. Maybe some sort of accessibility option can enable it :?

_________________
macOS 10.14 Mojave, PB 5.62 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 1:56 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 24, 2011 1:36 pm
Posts: 276
Hmm odd, purebasic does it on the debug window when you run a program and click the title of the debug window, the "Copy all" button is already selected with a blue border.

Thanks thought, I'll keep looking.


Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 3:58 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1648
Location: Germany
The solution is very easy and doesn't require any API. You only need to use
Code:
SetActiveGadget(#ButtonGadget)
and voilà: your button displays the wanted blue border and you may change the focus by using the <Tab> key... :wink:
Code:
OpenWindow(0, 270, 100, 200, 145, "Highlighted button")
ButtonGadget(0, 40, 20, 120, 25, "Test 1")
ButtonGadget(1, 40, 60, 120, 25, "Test 2")
ButtonGadget(2, 40, 100, 120, 25, "Test 3")
SetActiveGadget(0)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: Button focus or lack of it
PostPosted: Thu Mar 24, 2016 4:10 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 24, 2011 1:36 pm
Posts: 276
Ha! So simple I overlooked it, thanks Shardik


Top
 Profile  
Reply with quote  
 Post subject: Re: [solved] Button focus or lack of it
PostPosted: Mon Jul 08, 2019 6:51 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Mar 27, 2009 9:41 am
Posts: 719
Location: Athens, Greece
Some windows apps, not writen in PB, gives you the opportunity to write something in a textbox, the active button remains active while typing and by pressing keyboard Enter the button is pressed and does the job it should do. Is there a way to achieve it?


Top
 Profile  
Reply with quote  
 Post subject: Re: [solved] Button focus or lack of it
PostPosted: Mon Jul 08, 2019 8:21 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1905
Location: Germany
Update...

Is better to add and remove shortcut key

Code:
;-TOP

Enumeration formMenu
  #Menu_Return
EndEnumeration

OpenWindow(0, 270, 100, 200, 145, "Highlighted button")
ButtonGadget(0, 40, 20, 120, 25, "Ok", #PB_Button_Default)
ButtonGadget(1, 40, 60, 120, 25, "Cancel")
StringGadget(2, 40, 100, 120, 25, "Text")
SetActiveGadget(0)


; AddKeyboardShortcut(0, #PB_Shortcut_Return, #Menu_Return)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Menu
      Select EventMenu()
        Case #Menu_Return
          ;Debug GetGadgetText(2)
          PostEvent(#PB_Event_Gadget, 0, 0, #PB_EventType_LeftClick)
         
      EndSelect
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Debug "Button Ok - " + GetGadgetText(2)
        Case 1
          Debug "Button Cancel"
        Case 2
          If EventType() = #PB_EventType_Focus
            AddKeyboardShortcut(0, #PB_Shortcut_Return, #Menu_Return)
          ElseIf EventType() = #PB_EventType_LostFocus
            RemoveKeyboardShortcut(0, #PB_Shortcut_Return)
          EndIf
           
      EndSelect
 
  EndSelect
ForEver

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 26 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