I’ve been hacking on another sexy GtkEntry subclass, but this time, it’s not part of libsexy. It’s part of libview, VMware’s Incredibly Exciting Widgets. One of our developers built an IP Entry widget a short while ago, but it had some issues and just felt hard to use. I’ve never liked IP entries, particularly the windows ones, as they just felt too rigid and limiting. I always felt that I had to learn how to work for the widget instead of the widget working for me.
So I set out to do this right. I created a FieldEntry widget that is a GtkEntry subclass for displaying fields and validating fields. Users see delimiters spaced out evenly across the widget, just far enough for the content they are to display. Each field is center-aligned (this will be customizable in subclasses soon). The IPEntry subclasses this.
Now, the Windows IP entry are annoying for several reasons. I would like to list them now:
- You can’t copy or paste an IP address. You can only copy or paste one field of the IP address.
- Typing three digits in a field automatically jumps to the next field. If you made a mistake, you have to move the cursor to the left field and retype.
- Clicking inbetween fields causes the very first field to be selected.
I know there are others. I’m just tired.
So, I’ve addressed all of these. Copying and pasting work beautifully. When you type three characters of an IP entry field (or maxFieldWidth of whatever the FieldEntry has set) it doesn’t jump to the next field. However, if you start typing the next number (which is what you do on the Windows one) it will then jump to the next field and insert the text. Typing the delimiter (‘.’ on IP entries) will jump as well. Backspacing just works, even across fields. Clicking inbetween fields moves to the nearest field. And much more!
Bottom line: It feels natural to use. It’s there largely as a visual aid, and to allow you to easily get to fields, and such. But it doesn’t force you to type in a certain model. If you’re used to the Windows one, this will feel natural. If you’re used to just typing an IP address into an entry, this will feel natural. I’m quite happy with this one.
Now, it’s written in C++ for GTKMM, so if you want to use it in your C program, you’ll have to port it. I would love to see any ports that people wish to do, but mainly, I’d want to see this in GTK+ someday. We’ll see.
It’s available in libview cvs on SourceForge (see the link above) in the “staging” branch (as it’s pending review for inclusion in HEAD). Please, if you find any bugs or have usability issues, I’d love to know them.
Update: As requested, a screenshot!