Skip to content
Snippets Groups Projects
Commit ce7e8eb9 authored by Pell Smit's avatar Pell Smit
Browse files

fixed: bad behavior of input window

parent ebd94bf0
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
@interface LLNonInlineTextView : NSTextView @interface LLNonInlineTextView : NSTextView
{ {
LLOpenGLView *glview; LLOpenGLView *glview;
unichar mKeyPressed;
} }
- (void) setGLView:(LLOpenGLView*)view; - (void) setGLView:(LLOpenGLView*)view;
......
...@@ -642,37 +642,63 @@ attributedStringInfo getSegments(NSAttributedString *str) ...@@ -642,37 +642,63 @@ attributedStringInfo getSegments(NSAttributedString *str)
@implementation LLNonInlineTextView @implementation LLNonInlineTextView
/* Input Window is a legacy of 20 century, so we want to remove related classes.
But unfortunately, Viwer web browser has no support for modern inline input,
we need to leave these classes...
We will be back to get rid of Input Window after fixing viewer web browser.
How Input Window should work:
1) Input Window must not be empty.
It must close when it become empty result of edithing.
2) Input Window must not close when it still has input data.
It must keep open user types next char before commit. by Pell Smit
*/
- (void) setGLView:(LLOpenGLView *)view - (void) setGLView:(LLOpenGLView *)view
{ {
glview = view; glview = view;
} }
- (void) insertText:(id)insertString - (void)keyDown:(NSEvent *)theEvent
{ {
[[self inputContext] discardMarkedText]; // mKeyPressed is used later to determine whethere Input Window should close or not
[self setString:@""]; mKeyPressed = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
[_window orderOut:_window]; // setMarkedText and insertText is called indirectly from inside keyDown: method
[self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])]; [super keyDown:theEvent];
} }
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange // setMarkedText: is called for incomplete input(on the way to conversion).
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
{ {
[glview insertText:aString replacementRange:replacementRange]; [super setMarkedText:aString selectedRange:selectedRange replacementRange:replacementRange];
if ([aString length] == 0) // this means Input Widow becomes empty
{
[_window orderOut:_window]; // Close this to avoid empty Input Window
}
} }
- (void) insertNewline:(id)sender // insertText: is called for inserting commited text.
// There are two ways to be called here:
// a) explicitly commited (must close)
// In case of user typed commit key(usually return key) or delete key or something
// b) automatically commited (must not close)
// In case of user typed next letter after conversion
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
{ {
[[self textStorage] setValue:@""]; [[self inputContext] discardMarkedText];
[[self inputContext] discardMarkedText];
[self setString:@""]; [self setString:@""];
} [glview insertText:aString replacementRange:replacementRange];
if (mKeyPressed == NSEnterCharacter ||
- (void)doCommandBySelector:(SEL)aSelector mKeyPressed == NSBackspaceCharacter ||
{ mKeyPressed == NSTabCharacter ||
if (aSelector == @selector(insertNewline:)) mKeyPressed == NSNewlineCharacter ||
{ mKeyPressed == NSCarriageReturnCharacter ||
[self insertNewline:self]; mKeyPressed == NSDeleteCharacter ||
} (mKeyPressed >= 0xF700 && mKeyPressed <= 0xF8FF))
{
// this is case a) of above comment
[_window orderOut:_window]; // to avoid empty Input Window
}
} }
@end @end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment