Hello... thank you for your reply. But let me add to my question, what is the most appropriate way to provide a widget that supports monetary values? Given that the valid monetary values to be supported are going to be locale specific how can this be done in a portable way? Thanks, Neil On Mon, 29 Nov 2004 07:29:03 -0800, Vlietstra, Joe (NSSD) <joe.vlietstra@xxxxxxx> wrote: > Neil Zanella <nzanella@xxxxxxxxx> wrote: > > > > I've got a GtkEntry and I need to confine user input into this widget > > to numeric values which will fit into the underlying C data types. > > What is the best way to do this? If the values were only allowed to > > be integers I'd use a GtkSpinBox (I think that's what it's > called), > > but since they are now allowed to have decimal points etc... > > what should I do to be sure the user doesn't enter invalid data. > > What's the best way? > > GtkSpinButton will work for both integer and floating-point numbers. > See "Example 2" in the API documentation at: > http://developer.gnome.org/doc/API/2.0/gtk/GtkSpinButton.html > > We use spin buttons in instrumentation control (power supplies, > RF sources, etc.). Spin button range checking works well and our > operators like the up/down arrows. > > There are three properties of spin buttons that you may need to think > about: > -- Non-numeric characters > Default spin button behavior reacts to non-numeric keys. > We've never found a use/benefit for this behavior (hex entry?). > Use gtk_spin_button_set_numeric to ignore non-numeric characters. > API documentation is contradictory (description of "numeric" > parameter is opposite of function summary). Set the "numeric" > parameter to TRUE to ignore non-numeric characters. > -- Snap to tick > Default spin button behavior allows operator to enter a value > that is not on a "tick" (up/down arrow) boundary. This is > desirable most of the time but you may need to call > gtk_spin_button_set_snap_to_ticks to change this behavior. > Example: Resolution of RF synthesizer hardware is 0.02 dB. > Synthesizer will accept commands at finer resolution and > quietly change the RF output to the nearest 0.02 dB tick. > Better to have the application snap to tick than the hardware. > -- Update policy > 99% of the time the default policy (GTK_UPDATE_ALWAYS) is what > you want. The spin button will be able to display a value that > isn't in the range of the adjustment. This can be handy. > Example: Application will query the voltage level from a DC > power supply during initialization and display it in the spin > button; this voltage level may be out of range but you need to > inform the operator of the actual level. > > Joe Vlietstra > _______________________________________________ > > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list > _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list