Re: Space Bar Issue

developer wrote:
> Hi List,
> On the app I am making, when I press the space bar,
> it is treated as a left mouse click on any one of
> the gtk2 buttons on the screen at the time, and
> even a click on a gtk2 button that used to be on
> the screen.

More precisely, the space bar is "activating" the currently focused button. 
It doesn't happen at random, it takes effect on the button with the keyboard

> I don't want the users of my app to change screens
> or activate functions by pressing the space bar.
> But that's exactly what happens. Pressing the
> space bar behaves like left clicking on a button.

This is one of gtk+'s selling points, that it can be driven with the keyboard.
 This is important for systems without a mouse, or with a broken mouse, or for
doing things more quickly than a mouse will allow, for accessibility, etc,
etc.  Recall that the user can cycle through the buttons and entries etc of a
window by hitting the Tab key; i for one make use of this every day to keep
from having to grab the mouse for every little thing.

> And I don't even choose which button gets activated.

By default, the first focusable widget in a window is given keyboard focus. 
You can, of course, change this.

You can choose which widget in a window gets keyboard focus:

   $window->set_focus ($widget);

You can choose which widget in a window is the "default", such that when the
user activates the default action for a window (e.g., by pressing enter in a
single-line text entry), this is the widget that gets activated:

   $window->set_default ($widget);

You can choose which response of a dialog is the default:

   $dialog->set_default_response ('ok');

You can prevent a widget from being able to have keyboard focus, although this
is not recommended:

   $widget->can_focus (FALSE);


Thanks for all of your collective help.

I believe I understand what all of you are
saying. I was not setting which widget got
focus when the screen was displayed, but I
am having trouble with that.

I have a fullscreen window. I have loaded
a perl package into this window. This perl
package covers all of the screen real estate
and populates the top 1/4 of the window with
buttons using a Gtk2::Fixed widget to set
them in place.  The bottom 3/4 of the 
window is blank because I didn't place 
any widgets there using the "fixed" widget.
All 18 of the buttons in the top 1/4 of
the window remain static.(i.e, always displayed).

It is the bottom 3/4 of the window where I
swap perl packages in and out to change
the purpose of the screen, each screen being
a perl package put in place using the
"fixed" widget mentioned earlier. I have
120 of these I am working with. When
I load in one of these packages,
I use (e.g., $button->grab_focus; or I use
$label->grab_focus; or $entry->grab_focus
but they do not have the focus, for when I
press the spacebar, my "CANCEL" button is
activated and the previous package is loaded.
My "CANCEL" button is the last widget on
the screen in each package.

I'm either using this technique wrong, or
I am experiencing a bug of some sort.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]