diff options
-rw-r--r-- | dw/fltkui.cc | 5 | ||||
-rw-r--r-- | dw/fltkui.hh | 1 | ||||
-rw-r--r-- | dw/ui.hh | 1 | ||||
-rw-r--r-- | src/form.cc | 9 |
4 files changed, 12 insertions, 4 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index e8416bb3..14914dfe 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -670,6 +670,11 @@ void FltkEntryResource::setEditable (bool editable) this->editable = editable; } +void FltkEntryResource::setMaxLength (int maxlen) +{ + ((Fl_Input *)widget)->maximum_size(maxlen); +} + // ---------------------------------------------------------------------- FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, diff --git a/dw/fltkui.hh b/dw/fltkui.hh index 976e5395..e1845abd 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -308,6 +308,7 @@ public: void setText (const char *text); bool isEditable (); void setEditable (bool editable); + void setMaxLength (int maxlen); }; @@ -482,6 +482,7 @@ class EntryResource: public TextResource { public: enum { UNLIMITED_SIZE = -1 }; + virtual void setMaxLength (int maxlen) = 0; }; class MultiLineTextResource: public TextResource diff --git a/src/form.cc b/src/form.cc index b495e7b4..b128c411 100644 --- a/src/form.cc +++ b/src/form.cc @@ -548,10 +548,11 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) if (a_Html_get_attr(html, tag, tagsize, "readonly")) ((EntryResource *) resource)->setEditable(false); -// /* Maximum length of the text in the entry */ -// if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "maxlength"))) -// gtk_entry_set_max_length(GTK_ENTRY(widget), -// strtol(attrbuf, NULL, 10)); + /* Maximum length of the text in the entry */ + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "maxlength"))) { + int maxlen = strtol(attrbuf, NULL, 10); + ((EntryResource *) resource)->setMaxLength(maxlen); + } } if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { |