Silverfrost Forums

Welcome to our forums

Keep focus off of button

20 Mar 2014 4:11 #13876

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]'

20 Mar 2014 7:56 #13877

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

20 Mar 2014 8:06 #13878

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

20 Mar 2014 8:29 #13879

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

21 Mar 2014 2:16 #13880

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.

21 Mar 2014 2:49 #13881

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
21 Mar 2014 5:25 #13882

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.

22 Mar 2014 6:31 #13885

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

Please login to reply.