DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2704
Version: 1.3.0


Attached file "cursor-problem-v2.cxx"...


Link: http://www.fltk.org/str.php?L2704
Version: 1.3.0
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Text_Editor.H>
#include <FL/Fl_Text_Buffer.H>

class MyOneLineInput : public Fl_Text_Editor {
    // Example: prevent user from hitting 'Enter' by deleting it as soon as 
it's typed.
    static void ModifyCallback(int pos, int nins, int ndel, int nrest, const 
char *deltext, void *cbdata) {
        MyOneLineInput *edit = (MyOneLineInput*)cbdata;
        if ( nins > 0 && edit->buffer()->text()[pos] == 10 ) {  // disallow 
typing of CR
            int pos = edit->insert_position();                  // save insert 
position
            edit->buffer()->remove(pos,pos+1);
            edit->insert_position(pos);                         // restore 
insert position
/*** NONE OF THIS SEEMS TO HELP
            Fl::focus(edit);
            edit->insert_position(1);
            edit->show_cursor(1);
            edit->cursor_style(NORMAL_CURSOR);
            edit->cursor_color(FL_BLACK);
***/
        }
    }
public:
    MyOneLineInput(int X,int Y,int W,int H,const char *L=0) : 
Fl_Text_Editor(X,Y,W,H,L) {
        buffer(new Fl_Text_Buffer());                                   // set 
up buffer
        buffer()->add_modify_callback(ModifyCallback, (void*)this);     // set 
up mod callback
    }

    void value(const char *s) {
        buffer()->text(s);
    }
    const char *value(void) const {
        return(buffer()->text());
    }
};

int main(int argc, char **argv) {
    Fl_Double_Window *main_win = new Fl_Double_Window(460, 496, "Tiled Window");
    MyOneLineInput *in = new MyOneLineInput(140,10,300,70,"MyOneLineInput");
    main_win->resizable(main_win);
    main_win->show(argc, argv);
    return Fl::run();
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to