Create dialog for editing large terrain object definitions

- Remove keybindings from terrain dialog arrow buttons
- Fix arrow buttons not bound-checking fields

Dialog engine:
- Fix fields crashing after text is set while it has focus
- Trigger focus handler on untoast() to balance that in toast()
This commit is contained in:
2015-01-22 10:22:59 -05:00
parent 5315655bc6
commit 6a08476d22
7 changed files with 142 additions and 8 deletions

View File

@@ -1246,6 +1246,8 @@ bool cDialog::toast(bool triggerFocus){
void cDialog::untoast() {
dialogNotToast = true;
if(!currentFocus.empty())
this->getControl(currentFocus).triggerFocusHandler(*this, currentFocus, false);
}
bool cDialog::accepted() {

View File

@@ -59,6 +59,14 @@ bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFoc
return passed;
}
void cTextField::setText(std::string to) {
cControl::setText(to);
if(haveFocus)
insertionPoint = to.length();
else insertionPoint = -1;
selectionPoint = 0;
}
void cTextField::set_ip(location clickLoc, int cTextField::* insertionPoint) {
TextStyle style;
style.font = FONT_PLAIN;
@@ -480,7 +488,11 @@ void cTextField::handleInput(cKey key) {
case key_insert:
break;
}
// Setting the text normally resets insertion/selection point, but we don't want that here.
int ip = insertionPoint, sp = selectionPoint;
setText(contents);
insertionPoint = ip;
selectionPoint = sp;
}
cControl::storage_t cTextField::store() {

View File

@@ -41,6 +41,7 @@ public:
void setFormat(eFormat prop, short val) throw(xUnsupportedProp);
short getFormat(eFormat prop) throw(xUnsupportedProp);
void setColour(sf::Color clr) throw(xUnsupportedProp);
void setText(std::string to);
storage_t store();
void restore(storage_t to);
/// Get the current input type of the field.