forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Keep focus off of button

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Clay



Joined: 20 Mar 2014
Posts: 23

PostPosted: Thu Mar 20, 2014 5:11 pm    Post subject: Keep focus off of button Reply with quote

I’m building a “dash board” window using winio@ statements. The dash board has several menu items, but only a single button which is an “Exit” button. The problem is that anytime the dash board takes the focus (new dashboard drawn or user selection in Windows) the Exit button gets highlighted and if subsequently the Enter key or Space Bar get pressed then the application exits. Is there a way to draw the Exit button so that it is never highlighted? Second preference is at least it isn’t the default item highlighted first. By highlighted I mean that it has a dashed line drawn around the inside perimeter of the button and Enter or Spacebar act the same as clicking the button with the mouse. Syntax I’m using for the Exit button is '%ts%`ap%BC%^5BT[Exit]'
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Mar 20, 2014 8:56 pm    Post subject: Reply with quote

Give the button a ~ modifier, and add an integer parameter to control whether the button is greyed-out. It is dealt with in the help file. You can ungrey the button when the program needs to have Exit active.

Eddie
Back to top
View user's profile Send private message
Clay



Joined: 20 Mar 2014
Posts: 23

PostPosted: Thu Mar 20, 2014 9:06 pm    Post subject: Reply with quote

Thank you for the reply, Eddie.

I always want the Exit button to be available, but I only want it to be activated if the user clicks on the button. What's happening now is this: the program is running in the back ground and the user is typing an email or doing something else. Suddenly the dash board gets activated and the focus is on the Exit button. Before the user knows it, a stray key stroke exits the application. I could guard against an early exit with a "confirm exit" pop up, but I think that would be annoying. It would be best if only a mouse click could activate the button.

Clay
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Mar 20, 2014 9:29 pm    Post subject: Reply with quote

Clay,

What about another button 'Activate Exit command'? (Or a menu item for it).

You could have a button for some other function that you don't mind being accidentally activated, e.g. 'Help', and make that one the default button.

Or you could put the 'Exit' button on a toolbar, or perhaps a clickable graphic.

You can also interrogate the callback reason in the callback function for the button, and refuse to operate if it is other than a mouse click. See CLEARWIN_STRING@ function and CALLBACK_REASON.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Mar 21, 2014 3:16 pm    Post subject: Reply with quote

You need the grave accent with %bt to get it to respond to ENTER.
So %`bt[Exit] will exit when you press ENTER.

Otherwise none of the following alternatives will respond to pressing the ENTER key but will exit when you click on the button...

winio@(%bt[Exit])

winio@(%^bt[Exit], "EXIT")

winio@(%^bt[Exit], exitCB)

with

integer function exitCB()
exitCB = 0
return

The other modifiers for %bt have no impact on this behaviour.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Mar 21, 2014 3:49 pm    Post subject: Reply with quote

Paul,

You are right that [Return] doesn't trigger this button, but [Spacebar] does, and [Tab] followed by [Return] triggers it too.

Eddie

Code:
      WINAPP
      PROGRAM A
      INCLUDE <WINDOWS.INS>
      I = WINIO@('%ca[Button]%5^bt[Exit]', 'EXIT')
      END
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Mar 21, 2014 6:25 pm    Post subject: Reply with quote

TAB followed by ENTER gives an expected response but (for me) the response to pressing the space bar is not expected.

Is this useful or is it just a bug?
Even if it is useful we may need an option to switch it off.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Mar 22, 2014 7:31 pm    Post subject: Reply with quote

Who knows if it is useful or a bug? Windows contains many keyboard shortcuts that hark back to the way PCs used to be or how you might operate them without a mouse - I assumed that [Return] would trigger the Exit as stated by Clay until I tried it. I'd hate to call it a bug, as it might be a vital behaviour for some users!

E
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group