hades
4 years ago
5 changed files with 103 additions and 1 deletions
@ -0,0 +1,31 @@ |
|||||||
|
package com.fr.grid.action; |
||||||
|
|
||||||
|
import com.fr.design.os.impl.SupportOSImpl; |
||||||
|
import com.fr.grid.Grid; |
||||||
|
import com.fr.grid.help.GridHelper; |
||||||
|
import com.fr.stable.os.support.OSBasedAction; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/8/12 |
||||||
|
*/ |
||||||
|
public class GridInputAction implements OSBasedAction { |
||||||
|
|
||||||
|
private Grid grid; |
||||||
|
private char ch; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void execute(Object... objects) { |
||||||
|
// win下韩语输入法与其他输入法不一样 在输入第二个字符时 就开始触发keyType 而其中grid的焦点转移会导致输入失效
|
||||||
|
boolean accept = SupportOSImpl.KOREAN_INPUT.support() && grid != null; |
||||||
|
if (accept) { |
||||||
|
grid.setNeedRequestFocus(!GridHelper.isKoreanCharacter(ch)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void register(Grid grid, char ch) { |
||||||
|
this.grid = grid; |
||||||
|
this.ch = ch; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.grid.help; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/8/7 |
||||||
|
*/ |
||||||
|
public class GridHelper { |
||||||
|
|
||||||
|
private static final char X_AC00 = 0xAC00; |
||||||
|
private static final char X_D7A3 = 0xD7A3; |
||||||
|
private static final char X_3130 = 0x3130; |
||||||
|
private static final char X_318F = 0x318F; |
||||||
|
private static final char X_1100 = 0x1100; |
||||||
|
private static final char X_11FF = 0x11FF; |
||||||
|
private static final char X_20A9 = 0x20A9; |
||||||
|
|
||||||
|
public static boolean isKoreanCharacter(char value) { |
||||||
|
return value >= X_AC00 && value <= X_D7A3 |
||||||
|
|| value > X_3130 && value < X_318F |
||||||
|
|| value > X_1100 && value < X_11FF |
||||||
|
|| value == X_20A9; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.fr.grid.help; |
||||||
|
|
||||||
|
import junit.framework.TestCase; |
||||||
|
import org.junit.Assert; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/8/7 |
||||||
|
*/ |
||||||
|
public class GridHelperTest extends TestCase { |
||||||
|
|
||||||
|
/** |
||||||
|
* 为空 |
||||||
|
*/ |
||||||
|
private char ch; |
||||||
|
|
||||||
|
public void testIsKoreanCharacter() { |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('1')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('A')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('z')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('测')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('測')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('鐪')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('&')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter(' ')); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter(ch)); |
||||||
|
Assert.assertFalse(GridHelper.isKoreanCharacter('は')); |
||||||
|
Assert.assertTrue(GridHelper.isKoreanCharacter('먀')); |
||||||
|
Assert.assertTrue(GridHelper.isKoreanCharacter('이')); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue