[Glade-users] How to block some input in GtkEntry field
- From: virtualex at linuxoid.net (virtualex at linuxoid.net)
- Subject: [Glade-users] How to block some input in GtkEntry field
- Date: Thu, 26 Aug 2010 08:24:42 -0700
Quoting Arthur Shats <ashats at hotmail.com>:
What exactly are we blocking/unblocking with the calls to
g_signal_handlers_block_by_func and _unblock_by_func and why we need
to do this?
If you won't do it you'll receive the callback again on the string
you've already validated, and you'll face infinite recursion.
Also, since we are typing char by char, the text argument seem to
contain only one char at a time and the length arg is 1 and so the
result string is going to have only one char, so why do we need to
have a loop?
That is the difference between "key-press-event" and "insert-text".
Consider that user would likely want to copy and paste the whole IP
address copied from somewhere instead of typing it. In this case you
wouldn't get any "key-press-event" at all, but have to process the
whole string in one "insert-text" callback. For that reason the
"key-press-event" is not suitable for input validation, but could be
handy if you want to implement some nice extra functionality, like
moving cursor to the next octet if tab was pressed,
incrementing/decrementing octet on cursor up/down, etc.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]