Page 1 of 1

An Extra Option for buttons and a Thank You

Posted: Sat Apr 05, 2008 9:54 am
by xProgrammer
Firstly a big thank you to Antonio for his recent help changing default selection when tabbing through GETs. Combined with my workaround for controlling tab order it has made for some nice comments from my end users and made them more productive.

Whilst I was controlling the order when tabbing through GETs and keeping buttons that should not have been tabbed through avoided, there remained the issue of these buttons grabbing the focus when clicked on.

That was relatively easy to fix by adding the following code to buttons.c

Code: Select all

HB_FUNC( BTNNOFOCUS ) 
{
  gtk_button_set_focus_on_click( GTK_BUTTON( hb_parnl( 1 ) ), FALSE );
}
and this to button.prg

Code: Select all

   METHOD SetNoFocusOnClick() INLINE BtnNoFocus( ::hWnd )
now if you code as follows

Code: Select all

oBtn:SetNoFocusOnClick()
then when you click on oBtn the focus will stay set where it was.

I note that this might be very useful for buttons on toolbars.

Also a question to Antonio and other users. Should this be an option on BUTTON creation - in other words should @ row, col BUTTON command have a new clause, maybe NOFOCUS, to support such a capability directly rather than code along the following lines

Code: Select all

@ row, col BUTTON oBtn PROMPT "Some Prompt" ACTION( etc
oBtn:SetNoFocusOnClick()
just do it in one line

Code: Select all

@ row, col BUTTON "Some Prompt" NOFOCUS ACTION( etc
Regards
Doug
(xProgrammer)