X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=a8d3e55c35460abe482e076e4e165a2a5915b7a4;hb=587ba60f59f857c634198d4b815cf9bb1edbb0f0;hp=56c359bcc1a0e636c658430e578ef1e5f6e169e5;hpb=7bcc6aa833d64b21f78793dd00ed4c1356b98d05;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 56c359bc..a8d3e55c 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -879,7 +879,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) { int tag = first_tag; - if (gi == NULL || gi->deactivated) + if (gi == NULL) return; while (tag != GDI_END) @@ -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; @@ -1925,7 +1934,7 @@ boolean HandleGadgets(int mx, int my, int button) if (gadget_pressed) // gadget pressed the first time { // initialize delay counter - DelayReached(&pressed_delay, 0); + ResetDelayCounter(&pressed_delay); // start gadget delay with longer delay after first click on gadget pressed_delay_value = GADGET_FRAME_DELAY_FIRST; @@ -2228,12 +2237,34 @@ 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) + { strcpy(gi->textinput.value, gi->textinput.last_value); + 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();