On 07.01.2011 18:05, Brad wrote:
> I am using Fl_Secret_Input to provide a field where users can type
> password sentences. I have a Fl_Button named 'View Sentence' that allows
> users to see (but not edit) the sentence they have typed. When they
> click 'View Sentence', a fl_message displays the sentence.
>
> I would like to toggle the Fl_Secret_Input field to a Fl_Input field so
> the user could more easily see and edit the sentence upon input errors.
>
> I've tired putting Fl_Secret_Input and Fl_Input in the same location and
> switching between them, but that does not seem to work. I thought
> someone on this list may have implemented something similar, so I wanted
> to ask here.

Good idea to ask ;-) It's much easier than you thought.

Fl_Secret_Input is derived from Fl_Input_, and you can set the type()
to change its behavior. Here are the type definitions from the FLTK 1.3
docs (FLTK 1.1 is identical):

   #define FL_NORMAL_INPUT          0
   #define FL_FLOAT_INPUT           1
   #define FL_INT_INPUT             2
   #define FL_MULTILINE_INPUT       4
   #define FL_SECRET_INPUT          5
   #define FL_INPUT_TYPE            7
   #define FL_INPUT_READONLY        8
   #define FL_NORMAL_OUTPUT         (FL_NORMAL_INPUT | FL_INPUT_READONLY)
   #define FL_MULTILINE_OUTPUT      (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
   #define FL_INPUT_WRAP            16
   #define FL_MULTILINE_INPUT_WRAP  (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
   #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | 
FL_INPUT_READONLY | FL_INPUT_WRAP)

Basically you must set one of the type values in [0-5] and or this
with FL_INPUT_READONLY if you need it. Just change the type()
accordingly and call redraw(). You need only one widget.

Albrecht
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to