[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Question on gtk_label_set_selectable
- From: Gregory Hosler <ghosler redhat com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Question on gtk_label_set_selectable
- Date: Fri, 19 Oct 2007 21:02:44 +0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Ne?as (Yeti) wrote:
> On Fri, Oct 19, 2007 at 07:44:19PM +0800, Gregory Hosler wrote:
>> Gregory Hosler wrote:
>>> Hi all,
>>>
>>> I have labels, which I wish to allow the user to select the text for the purpose
>>> of cut/pasting. So I set
>>>
>>> gtk_label_set_selectable (GTK_LABEL (dlabel), 1)
>>>
>>> on the label.
>>>
>>> The problem I have now is that when the label is created, not only is the text
>>> selectable, but it is also SELECTED as an initial state. I would prefer for the
>>> text to be selectable, BUT NOT selected (at least as a default state).
>>>
>>> How might I turn off "selected" ?
>>>
>>> any tips ?
>> After some exploring, and looking at the gtk samples, I have an answer.
>> I'm not happy with it. It seems (to me) like there is a bug, so let me
>> explain what works, and what doesn't work.
>>
>> If I have a window (dwindow), and then create a label as follows:
>>
>> dlabel=gtk_label_new("");
>> gtk_label_set_text(GTK_LABEL(dlabel), "my text");
>> gtk_label_set_line_wrap(GTK_LABEL(dlabel),1);
>> gtk_label_set_selectable (GTK_LABEL (dlabel), 1);
>>
>> Then attach my label to the window and then:
>>
>> gtk_widget_show_all(dwindow);
>>
>> My label will show up, as selectable, BUT the label text will be
>> initially selected.
>>
>> If I change the above sequence to this:
>>
>> dlabel=gtk_label_new("");
>> gtk_label_set_text(GTK_LABEL(dlabel), "my text");
>> gtk_label_set_line_wrap(GTK_LABEL(dlabel),1);
>>
>> Then attach my label to the window and then:
>>
>> gtk_widget_show_all(dwindow);
>> gtk_label_set_selectable (GTK_LABEL (dlabel), 1);
>>
>> i.e. setting the selectable attribute AFTER the label is realized,
>> created, etc. *then* the label text will NOT be selected (but it is
>> still selectable).
>>
>> I do not understand why in one case the initial state of the text is
>> "selected" and in the 2nd case it is NOT "selected".
>>
>> Is this a bug? Or is there a reason this is like this?
>>
>> thoughts ?
>
> I have not seen the code, but...
>
> Your label the first widget in the window that accepts focus
> (selectable labels can receive focus, unlike normal labels).
> Therefore the label will get focus, which selects its text
> -- at least this seems to be the default behaviour.
>
> If you add the label after it's decided which widget should
> receive focus, the label does not get focus and therefore
> its text is not selected.
interesting thought.
The label is in a dialog box with one or 2 buttons. I guess I need to
put the focus onto the default button.
I'll give that a try, and see what happens.
Thanks,
- -Greg
> Yeti
>
> --
> http://gwyddion.net/
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
- --
+---------------------------------------------------------------------+
Please also check the log file at "/dev/null" for additional information.
(from /var/log/Xorg.setup.log)
| Greg Hosler ghosler redhat com |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFHGKrz404fl/0CV/QRAhwRAJ9fMZr0G0o4h7sK88MVP7t9bi+SxACfdqcx
wxwm32RQGTyNbIX8+JCgNsc=
=EJwv
-----END PGP SIGNATURE-----
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]