src/osk_gui.cpp
changeset 10538 8d2fcedeb9e9
parent 10499 9c2d9bdea61a
child 10539 42f48cb0d302
equal deleted inserted replaced
10537:116b667a5956 10538:8d2fcedeb9e9
   127 				this->SetDirty();
   127 				this->SetDirty();
   128 			}
   128 			}
   129 			return;
   129 			return;
   130 		}
   130 		}
   131 
   131 
       
   132 		bool delete_this = false;
       
   133 
   132 		switch (widget) {
   134 		switch (widget) {
   133 			case OSK_WIDGET_BACKSPACE:
   135 			case OSK_WIDGET_BACKSPACE:
   134 				if (DeleteTextBufferChar(&this->qs->text, WKC_BACKSPACE)) this->InvalidateWidget(OSK_WIDGET_TEXT);
   136 				if (DeleteTextBufferChar(&this->qs->text, WKC_BACKSPACE)) this->InvalidateWidget(OSK_WIDGET_TEXT);
   135 				break;
   137 				break;
   136 
   138 
   169 					/* pass information by simulating a button press on parent window */
   171 					/* pass information by simulating a button press on parent window */
   170 					if (this->ok_btn != 0) {
   172 					if (this->ok_btn != 0) {
   171 						this->parent->OnClick(pt, this->ok_btn);
   173 						this->parent->OnClick(pt, this->ok_btn);
   172 					}
   174 					}
   173 				}
   175 				}
   174 				delete this;
   176 				delete_this = true;
   175 				break;
   177 				break;
   176 
   178 
   177 			case OSK_WIDGET_CANCEL:
   179 			case OSK_WIDGET_CANCEL:
   178 				if (this->cancel_btn != 0) { // pass a cancel event to the parent window
   180 				if (this->cancel_btn != 0) { // pass a cancel event to the parent window
   179 					this->parent->OnClick(pt, this->cancel_btn);
   181 					this->parent->OnClick(pt, this->cancel_btn);
   180 					/* Window gets deleted when the parent window removes itself. */
   182 					/* Window gets deleted when the parent window removes itself. */
   181 				} else { // or reset to original string
   183 				} else { // or reset to original string
   182 					strcpy(qs->text.buf, this->orig_str_buf);
   184 					strcpy(qs->text.buf, this->orig_str_buf);
   183 					UpdateTextBufferSize(&qs->text);
   185 					UpdateTextBufferSize(&qs->text);
   184 					MoveTextBufferPos(&qs->text, WKC_END);
   186 					MoveTextBufferPos(&qs->text, WKC_END);
   185 					delete this;
   187 					delete_this = true;
   186 				}
   188 				}
   187 				break;
   189 				break;
   188 		}
   190 		}
   189 		/* make sure that the parent window's textbox also gets updated */
   191 		/* make sure that the parent window's textbox also gets updated */
   190 		if (this->parent != NULL) this->parent->InvalidateWidget(this->text_btn);
   192 		if (this->parent != NULL) this->parent->InvalidateWidget(this->text_btn);
       
   193 		if (delete_this) delete this;
   191 	}
   194 	}
   192 
   195 
   193 	virtual void OnMouseLoop()
   196 	virtual void OnMouseLoop()
   194 	{
   197 	{
   195 		this->qs->HandleEditBox(this, OSK_WIDGET_TEXT);
   198 		this->qs->HandleEditBox(this, OSK_WIDGET_TEXT);