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]'
Keep focus off of button
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
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
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
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.
Paul,
You are right that [Return] doesn't trigger this button, but [Spacebar] does, and [Tab] followed by [Return] triggers it too.
Eddie
WINAPP
PROGRAM A
INCLUDE <WINDOWS.INS>
I = WINIO@('%ca[Button]%5^bt[Exit]', 'EXIT')
END
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.
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