[gtkada] Gtk_Spin_Button and focus out signal.

Preben Randhol randhol at pvv.org
Wed May 8 17:46:03 CEST 2002


"Clark, G L" <g.l.clark at lmco.com> wrote on 08/05/2002 (16:53) :
>
> Hello All,
>
>    In my application I have implemented "focus out" handlers for my
> Spin_Button widgets which validates and stores the data.  However,
> internally "focus out" is used to update the value to a valid range... they
> no longer do this. The range is left invalid when data is read and it's
> causing all sorts of problems.
>    How do I go about forcing the spin_button to jump into a valid range in
> the "focus out" handler that I've implemented.

   procedure On_Some_Spin_Button_Focus
      (Object : access  Gtk_Spin_Button_Record'Class) is

      Value : GFloat := Get_Value_As_Float (Object);
      Adjustment : Gtk_Adjustment := Get_Adjustment (Object);
   begin

   if Value < Get_Lower (Adjustment) then
      Value := Get_Lower (Adjustment);
   elsif Value > Get_Upper (Adjustment) then
      Value := Get_Upper (Adjustment);
   end if;

   Set_Value (Adjustment, Value);
   Set_Adjustment (Object, Adjustment);

   end On_Some_Spin_Button_Focus;

Note I have not tested this. I have to run now as the shops close in 15
min due. Hope it helps.

--
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list