Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't input multi-byte charactor #96

Open
usounds opened this issue Dec 30, 2018 · 1 comment
Open

Can't input multi-byte charactor #96

usounds opened this issue Dec 30, 2018 · 1 comment

Comments

@usounds
Copy link

usounds commented Dec 30, 2018

No description provided.

@usounds
Copy link
Author

usounds commented Dec 30, 2018

This issue have from Wired Client v2.0.

The Japanese characters input 1char , using 2 and more keydown as follows.
ex) input "火" <- "k" key and "a" key and space key and enter key

In 'WCChatWindow.m', when keydown event occurred, the input force commit as "k" only.
The solution to this problem is to comment out as follows.
But I do not know the impact of doing this fix....

========================

/* $Id$ */

/*
 *  Copyright (c) 2006-2009 Axel Andersson
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "WCChatWindow.h"
#import "WCPublicChat.h"

@implementation WCChatWindow

- (void)sendEvent:(NSEvent *)event {
    static NSMutableCharacterSet    *characterSet;
    NSTextField                     *textField;
    BOOL                            handled = NO;

    if([event type] == NSKeyDown) {
        if(!characterSet) {
            characterSet = [[NSMutableCharacterSet alphanumericCharacterSet] retain];
            [characterSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
            [characterSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
            [characterSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
            [characterSet formUnionWithCharacterSet:[NSCharacterSet decomposableCharacterSet]];
            [characterSet formUnionWithCharacterSet:[NSCharacterSet decomposableCharacterSet]];
            [characterSet removeCharactersInString:@"\t"];
        }
        
        textField = [(WCPublicChat *)[self delegate] insertionTextField];
        NSText* fieldEditor = [self fieldEditor:YES forObject:textField];

        if(fieldEditor && [self firstResponder] != textField) {
            if([[event characters] isComposedOfCharactersFromSet:characterSet]) {
                // avoid string manipulation of composing characters like ` ^ ¨ etc.
                if(![[event characters] isComposedOfCharactersFromSet:[NSCharacterSet decomposableCharacterSet]]) {
                    // make the field first responder without losing selection
                    NSRange oldRange = fieldEditor.selectedRange;
                    
//                    [fieldEditor setSelectable:NO];
//                    [self makeFirstResponder:textField];
//                    [fieldEditor setSelectable:YES];
                    
                    if(oldRange.location != NSNotFound)
                        [fieldEditor setSelectedRange:oldRange];
                    
                    
                    if(fieldEditor.selectedRange.location != NSNotFound) {
//                        [textField setStringValue:[[textField stringValue] stringByReplacingCharactersInRange:fieldEditor.selectedRange withString:@""]];
                        [fieldEditor setSelectedRange:NSMakeRange(fieldEditor.selectedRange.location,0)];
                    } else {
                        [fieldEditor setSelectedRange:NSMakeRange([[fieldEditor string] length],0)];
                    }
                    [fieldEditor setNeedsDisplay:YES];
                }
            }
        }
    }

    if(!handled && event)
        [super sendEvent:event];
}



- (void)paste:(id)sender {
	NSTextField		*textField;

	textField = [(WCPublicChat *)[self delegate] insertionTextField];
	
	if(textField) {
        NSText* fieldEditor = [self fieldEditor:YES forObject:textField];
        
		[self makeFirstResponder:textField];
		[fieldEditor paste:sender];
	}
}

@end

@usounds usounds changed the title Can't Can't input multi-byte charactor Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant