LWUIT TextArea问题 [英] LWUIT TextArea question
本文介绍了LWUIT TextArea问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在不进入LCDUI窗口的情况下在textArea
中进行写入?
我想在LWUIT应用程序中编辑textArea
,但是每次尝试执行此操作时,该应用程序都会将我发送到LCDUI窗口.
Is there any way to write in a textArea
without going to a LCDUI window?
I want to edit my textArea
in my LWUIT app but everytime I try to do this, the app send me to a LCDUI window.
推荐答案
要禁用LWUIT编辑控件触发器,可以使用以下代码.
To disable the LWUIT edit control trigger you can use the following code.
textArea.setNativeTextboxTrigger(false);
您需要在LWUIT TextArea源代码中实现以下代码
You need to implement the following code in the LWUIT TextArea source code
static final String CLIENT_PROPERTY_FIRE_ACTION_TIMES = "FIRE-ACTION-TIMES";
static final String CLIENT_PROPERTY_DEAFULT_TEXT = "DEFAULT-TEXT";
public void setNativeTextboxTrigger(boolean enable) {
registerNativeTextboxTriggerEvent = enable;
static final String CLIENT_PROPERTY_FIRE_ACTION_TIMES = "FIRE-ACTION-TIMES";
static final String CLIENT_PROPERTY_DEAFULT_TEXT = "DEFAULT-TEXT";
try {
if( registerNativeTextboxTriggerEvent ) {
String text = null != ( text = getText() ) ? text : "";
this.putClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT, text);
this.putClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES, String.valueOf(0));
final UIManager m = UIManager.getInstance();
setNativeCommandsText(m.localize("ok", "OK"), m.localize("cancel", "Cancel"));
this.addActionListener(nativeTriggerListener = getNativeTriggerActionListener());
} else {
this.putClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT, null);
this.putClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES, null);
setNativeCommandsText(null, null);
if( null != nativeTriggerListener ) {
this.removeActionListener(nativeTriggerListener);
nativeTriggerListener = null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
ActionListener getNativeTriggerActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if( evt.getSource() instanceof TextArea ) {
final TextArea tar = (TextArea)evt.getSource();
final String textEntered = tar.getText().trim();
final String defaultText = (String)tar.getClientProperty(CLIENT_PROPERTY_DEAFULT_TEXT);
int fireActionTimes = Integer.parseInt((String)tar.getClientProperty(CLIENT_PROPERTY_FIRE_ACTION_TIMES));
++fireActionTimes;
int value = fireActionTimes % 2;
if( 0 == value ) {
fireActionTimes = 0;
if( textEntered.equals("") || textEntered.toUpperCase().equals(defaultText.toUpperCase())) {
tar.setText(defaultText);
}
triggeredNativeToLwuit(tar);
} else
//Switching to native edit screen
if( 0 < value ) {
if( textEntered.toUpperCase().equals(defaultText.toUpperCase()) ) {
tar.setText("");
}
triggeredLwuitToNative(tar);
}
}
}
};
}
这篇关于LWUIT TextArea问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文