X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=6c394d7ab2a6993ad080bc7a2b51de61aebd95ba;hb=d9459636e19bd84aad9ca46e20455b5c6aa44010;hp=f84815b0effb46f94ab5bc4f399e6a84f7864b73;hpb=0865ed73513e161be429a61c63913d58c9d145a3;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index f84815b0..6c394d7a 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1711,7 +1711,7 @@ boolean HandleGadgets(int mx, int my, int button) struct GadgetInfo *gi = last_gi; boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_LEAVING) != 0); - // check if text gadget has changed its value + // check if text input gadget has changed its value if (gi->type & GD_TYPE_TEXT_INPUT) { CheckRangeOfNumericInputGadget(gi); @@ -1722,6 +1722,15 @@ boolean HandleGadgets(int mx, int my, int button) gadget_changed = FALSE; } + // check if text area gadget has changed its value + if (gi->type & GD_TYPE_TEXT_AREA) + { + if (!strEqual(gi->textarea.last_value, gi->textarea.value)) + strcpy(gi->textarea.last_value, gi->textarea.value); + else + gadget_changed = FALSE; + } + // selectbox does not change its value when closed by clicking outside if (gi->type & GD_TYPE_SELECTBOX) gadget_changed = FALSE; @@ -2228,6 +2237,8 @@ boolean HandleGadgetsKeyInput(Key key) { if (anyTextGadgetActive()) { + boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_LEAVING) != 0); + // restore previous text (before activating text gadget) if (gi->type & GD_TYPE_TEXT_INPUT) { @@ -2236,8 +2247,24 @@ boolean HandleGadgetsKeyInput(Key key) CheckRangeOfNumericInputGadget(gi); } + // store current text for text area gadgets when pressing "Escape" key + if (gi->type & GD_TYPE_TEXT_AREA) + { + if (!strEqual(gi->textarea.last_value, gi->textarea.value)) + strcpy(gi->textarea.last_value, gi->textarea.value); + else + gadget_changed = FALSE; + } + DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); + if (gi->type & GD_TYPE_TEXT_AREA) + { + gi->event.type = GD_EVENT_TEXT_LEAVING; + + DoGadgetCallbackAction(gi, gadget_changed); + } + last_gi = NULL; StopTextInput();