Re: automatic selection of text in entries on focus in



Thanks a lot ! It works !

signal_focus_in_event() is still useful since it allows to get the widget's coordinates.

I suppose this is the weight of legacy…

Thanks again !
yann

On 02/04/12 16:00, Kjell Ahlstedt wrote:
2012-04-02 11:29, Yann Leydier skrev:
Hi,

I have entries that I fill when they get the focus. The text I set is
automatically selected and I don't want that. In my application, the
user should be able to append text immediately.

Neither set_position nor select_region have any effect.

I made my focus_in() callback return "true" to prevent the event from
being passed further, but this did not change anything.

Is there any way control this?

Thanks,
yann
I had to look into the source code of gtk+ and make some tests with gdb
to find out, and here's what I found:

The focus_in signal is emitted from the default handler of the
grab_focus signal. That default handler selects all the text after the
focus_in signal handler(s) have returned.

Try to connect a handler to Gtk::Widget::signal_grab_focus() and
deselect the text and position the cursor there. Perhaps you can just
change your focus_in handler to a grab_focus handler. Connect your
grab_focus handler _after_ the default handler (which is the default
behaviour of connect()).

Kjell


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