[gtkmm] Key Snooping / Key_Press_Event Howto?
- From: Jeff Gavin <jeff ezclick net>
- To: "'gtkmm-list'" <gtkmm-list gnome org>
- Subject: [gtkmm] Key Snooping / Key_Press_Event Howto?
- Date: Thu, 19 Jun 2003 08:32:08 -0500
I'm trying to validate an entry while the user types. I've read all the
posts on entry validation and I still don't know an answer. I would
like to create a entry that can validate a date while the user types it
in, but to simplify things on the initial version, I decided to create
an entry that only allows numbers to be typed in.
Keep in mind I come from a MS/VB background (I know, yech, ptooie, gross!).
From this experience, I have created entries that would intercept each
keystroke and decide weather to accept them or not.
For example this VB code snip would not allow the "UserCode" field to
accept certain characters. Changing the KeyAscii code to 0 prevents the
entry from accepting the keystroke:
Private Sub txtUserCode_KeyPress(KeyAscii As Integer)
' Check for invalid character and exclude them.
If InStr(1, " ~`! #$%^&*()_+-={}[]\|:;<>,./?'""", Chr(KeyAscii)) > 0 Then
KeyAscii = 0
End If
End Sub
I cannot figure out how to do this with gtk+/gtkmm. The key_press_event
seemed like an obvious candidate, but it only triggers when the user
presses shift/esc/ctrl. Maybe this is not such a good name for this
event if that's all it can do. Is there a way to make all the key
presses to be passed to the callback? I'm sure someone has had to solve
this type of problem before. How did you do it?
Best Regards,
Jeff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]