"Label" entries
- From: Matthew Braid <ptkperl mdb id au>
- To: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: "Label" entries
- Date: Thu, 30 Apr 2009 16:55:00 +1000
Hi,
I'm trying to create an entry that acts a bit like the entries found
in vista and on some websites - where if no data has been entered some
text is displayed in the entry, usually greyed out.
If a user clicks into (focus-in) while the grey text is displayed (ie,
the user has not previously entered any information) the grey text is
cleared and the cursor appears at the start ready for input.
When the user leaves the entry (focus-out), if they still haven't
entered anything the grey text reappears, otherwise whatever they
typed stays there.
I'm trying to do this to limit the number of labels cluttering my gui
- instead of:
URL Title: [.....] URL Address: [.....]
I'd prefer:
URL: [/Title/...][/Address/...]
I've got the focus-in and focus-out actions working fine, and I'm now
working on a subclass so that the get_text function will return '' if
nothing has been entered even if there is 'grey text' displayed, but
so far I can't see a way of making the text inside the entry grey (or
in fact making it change in any way). Gtk2::Ex::Entry::Pango looks
promising, but installing new packages is...problematic... in my
current environment.
I thought about doing some messing around by setting the entry to be
insensitive when unedited (looks greyed out), and putting an event box
over it to catch focus events (or in fact _any_ event), but this:
use Gtk2 "-init";
$mw = Gtk2::Window->new;
$e = Gtk2::Entry->new;
$e->set_text("TEXT");
$e->set_sensitive(0);
$f = Gtk2::EventBox->new;
$f->signal_connect(event => sub {print "HIT"});
$mw->add($f);
$f->add($e);
$f->set_above_child(1); # Even with this!
$mw->show_all; Gtk2->main
doesn't work.
Does anyone have any helpful ideas? I'm continuing on without the
colouring anyway in the hopes that a solution can just be added in.
TIA,
MB
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]