Don't swallow : keypresses in TimeEdit

Originally committed to SVN as r6883.
This commit is contained in:
Thomas Goyne 2012-05-28 14:18:40 +00:00
parent a3d7d2bbc0
commit 108c38b9bc
1 changed files with 41 additions and 42 deletions

View File

@ -148,58 +148,57 @@ void TimeEdit::OnKeyDown(wxKeyEvent &event) {
PasteTime(); PasteTime();
else else
event.Skip(); event.Skip();
return;
} }
// Shift-Insert would paste the stuff anyway // Shift-Insert would paste the stuff anyway
// but no one updates the private "time" variable. // but no one updates the private "time" variable.
else if (event.ShiftDown()) { if (event.ShiftDown() && key == WXK_INSERT) {
if (key == WXK_INSERT) PasteTime();
PasteTime(); return;
else
event.Skip();
} }
else {
// Translate numpad presses to normal numbers
if (key >= WXK_NUMPAD0 && key <= WXK_NUMPAD9)
key += '0' - WXK_NUMPAD0;
// If overwriting is disabled, we're in frame mode, or it's a key we // Translate numpad presses to normal numbers
// don't care about just let the standard processing happen if (key >= WXK_NUMPAD0 && key <= WXK_NUMPAD9)
event.Skip(); key += '0' - WXK_NUMPAD0;
if (byFrame) return;
if (insert) return;
if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.') return;
event.Skip(false); // If overwriting is disabled, we're in frame mode, or it's a key we
// don't care about just let the standard processing happen
event.Skip();
if (byFrame) return;
if (insert) return;
if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.') return;
long start = GetInsertionPoint(); event.Skip(false);
wxString text = GetValue();
// Delete does nothing long start = GetInsertionPoint();
if (key == WXK_DELETE) return; wxString text = GetValue();
// Back just moves cursor back one without deleting
if (key == WXK_BACK) {
if (start > 0)
SetInsertionPoint(start - 1);
return;
}
// Cursor is at the end so do nothing
if (start >= (long)text.size()) return;
// If the cursor is at punctuation, move it forward to the next digit // Delete does nothing
if (text[start] == ':' || text[start] == '.') if (key == WXK_DELETE) return;
++start; // Back just moves cursor back one without deleting
if (key == WXK_BACK) {
// : and . hop over punctuation but never insert anything if (start > 0)
if (key == ';' || key == '.') { SetInsertionPoint(start - 1);
SetInsertionPoint(start); return;
return;
}
// Overwrite the digit
time = text.Left(start) + (char)key + text.Mid(start + 1);
SetValue(time.GetASSFormated());
SetInsertionPoint(start + 1);
} }
// Cursor is at the end so do nothing
if (start >= (long)text.size()) return;
// If the cursor is at punctuation, move it forward to the next digit
if (text[start] == ':' || text[start] == '.')
++start;
// : and . hop over punctuation but never insert anything
if (key == ';' || key == '.') {
SetInsertionPoint(start);
return;
}
// Overwrite the digit
time = text.Left(start) + (char)key + text.Mid(start + 1);
SetValue(time.GetASSFormated());
SetInsertionPoint(start + 1);
} }
void TimeEdit::OnInsertChanged(agi::OptionValue const& opt) { void TimeEdit::OnInsertChanged(agi::OptionValue const& opt) {