PDA

View Full Version : Force numbers in Entry (masking)


toyg
01-21-2010, 05:16 AM
Hi,
I'm writing a small app for the N900 using Python / PyGTK.

Do you know what is the best / recommended way to have the user input numbers in an Entry without having to keep the Fn key pressed?

It is possible, I've seen it done by the calendar application, the contact application etc, however it seems like non-core apps never use this functionality.
I cannot use a Selector, because the range of possible values is simply too big and it would be quite annoying to have to scroll through it.

I thought about simply "intercepting" the pressed key and replacing it with the number, but it seems that doing this in GTK might be a bit convoluted. I hoped there was some sort of simple switch, like hildon_set_fn_key_lock :D

Thanks in advance,
Giacomo

qwerty12
01-21-2010, 05:19 AM
You want hildon-gtk-entry-set-input-mode() (http://maemo.org/api_refs/5.0/5.0-final/gtk/GtkEntry.html#hildon-gtk-entry-set-input-mode). Setting it to HILDON_GTK_INPUT_MODE_NUMERIC will only allow for numeric input. Feel free to combine the modes as needed :-)

Ah, Python... Don't know the Python equivalent, sorry...

toyg
01-21-2010, 05:48 AM
Thanks a lot! That gives me a good pointer, I'm sure there is a way of using it in Python.

Great, thanks again :)

qwerty12
01-21-2010, 05:55 AM
Thanks a lot! That gives me a good pointer, I'm sure there is a way of using it in Python.


This bug report is probably what you're after: https://bugs.maemo.org/show_bug.cgi?id=5184