mirror of https://github.com/OpenTTD/OpenTTD
(svn r26758) -Fix [FS#5972]: [OSX] Implement more of the text editing API to prevent crashes and improve IME support.
parent
9c55307629
commit
2b3b8c93e7
|
@ -477,16 +477,10 @@ HandleKeyPressResult Textbuf::HandleKeyPress(WChar key, uint16 keycode)
|
|||
|
||||
case WKC_RETURN: case WKC_NUM_ENTER: return HKPR_CONFIRM;
|
||||
|
||||
#ifdef WITH_COCOA
|
||||
case (WKC_META | 'V'):
|
||||
#endif
|
||||
case (WKC_CTRL | 'V'):
|
||||
edited = this->InsertClipboard();
|
||||
break;
|
||||
|
||||
#ifdef WITH_COCOA
|
||||
case (WKC_META | 'U'):
|
||||
#endif
|
||||
case (WKC_CTRL | 'U'):
|
||||
this->DeleteAll();
|
||||
edited = true;
|
||||
|
|
|
@ -1088,6 +1088,92 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Delete single character left of the cursor. */
|
||||
- (void)deleteBackward:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_BACKSPACE, 0);
|
||||
}
|
||||
|
||||
/** Delete word left of the cursor. */
|
||||
- (void)deleteWordBackward:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_BACKSPACE | WKC_CTRL, 0);
|
||||
}
|
||||
|
||||
/** Delete single character right of the cursor. */
|
||||
- (void)deleteForward:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_DELETE, 0);
|
||||
}
|
||||
|
||||
/** Delete word right of the cursor. */
|
||||
- (void)deleteWordForward:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_DELETE | WKC_CTRL, 0);
|
||||
}
|
||||
|
||||
/** Move cursor one character left. */
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_LEFT, 0);
|
||||
}
|
||||
|
||||
/** Move cursor one word left. */
|
||||
- (void)moveWordLeft:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_LEFT | WKC_CTRL, 0);
|
||||
}
|
||||
|
||||
/** Move cursor one character right. */
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_RIGHT, 0);
|
||||
}
|
||||
|
||||
/** Move cursor one word right. */
|
||||
- (void)moveWordRight:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_RIGHT | WKC_CTRL, 0);
|
||||
}
|
||||
|
||||
/** Move cursor to the start of the line. */
|
||||
- (void)moveToBeginningOfLine:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_HOME, 0);
|
||||
}
|
||||
|
||||
/** Move cursor to the end of the line. */
|
||||
- (void)moveToEndOfLine:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_END, 0);
|
||||
}
|
||||
|
||||
/** Scroll to the beginning of the document. */
|
||||
- (void)scrollToBeginningOfDocument:(id)sender
|
||||
{
|
||||
/* For compatibility with OTTD on Win/Linux. */
|
||||
[ self moveToBeginningOfLine:sender ];
|
||||
}
|
||||
|
||||
/** Scroll to the end of the document. */
|
||||
- (void)scrollToEndOfDocument:(id)sender
|
||||
{
|
||||
/* For compatibility with OTTD on Win/Linux. */
|
||||
[ self moveToEndOfLine:sender ];
|
||||
}
|
||||
|
||||
/** Return was pressed. */
|
||||
- (void)insertNewline:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_RETURN, '\r');
|
||||
}
|
||||
|
||||
/** Escape was pressed. */
|
||||
- (void)cancelOperation:(id)sender
|
||||
{
|
||||
if (EditBoxInGlobalFocus()) HandleKeypress(WKC_ESC, 0);
|
||||
}
|
||||
|
||||
/** Invoke the selector if we implement it. */
|
||||
- (void)doCommandBySelector:(SEL)aSelector
|
||||
{
|
||||
|
|
|
@ -290,6 +290,17 @@ static bool QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
|||
VideoDriver::GetInstance()->ToggleFullscreen(!_fullscreen);
|
||||
}
|
||||
break;
|
||||
|
||||
case QZ_v:
|
||||
if (down && EditBoxInGlobalFocus() && (_current_mods & (NSCommandKeyMask | NSControlKeyMask))) {
|
||||
HandleKeypress(WKC_CTRL | 'V', unicode);
|
||||
}
|
||||
break;
|
||||
case QZ_u:
|
||||
if (down && EditBoxInGlobalFocus() && (_current_mods & (NSCommandKeyMask | NSControlKeyMask))) {
|
||||
HandleKeypress(WKC_CTRL | 'U', unicode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (down) {
|
||||
|
@ -310,7 +321,7 @@ static bool QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
|||
console = false;
|
||||
|
||||
/* Don't handle normal characters if an edit box has the focus. */
|
||||
if (!EditBoxInGlobalFocus() || ((pressed_key & ~WKC_SPECIAL_KEYS) <= WKC_TAB) || IsInsideMM(pressed_key & ~WKC_SPECIAL_KEYS, WKC_F1, WKC_PAUSE + 1)) {
|
||||
if (!EditBoxInGlobalFocus() || IsInsideMM(pressed_key & ~WKC_SPECIAL_KEYS, WKC_F1, WKC_PAUSE + 1)) {
|
||||
HandleKeypress(pressed_key, unicode);
|
||||
}
|
||||
DEBUG(driver, 2, "cocoa_v: QZ_KeyEvent: %x (%x), down, mapping: %x", keycode, unicode, pressed_key);
|
||||
|
|
Loading…
Reference in New Issue