こんにちは、次のコードがあります。
okBtn.addEventListener(Events.ON_CLICK, new EventListener()
{
@Override
public void onEvent(final Event arg0) throws Exception
{
//when the user clicks on ok, we take the current
//string from fckeditor...
String currentValue = fckEditor.getValue();
// set the string to preview to the current value
html.setContent(currentValue);
}
});
私が直面している問題は、この fckEditor.getValue() (fckEditor は textArea に似ています) 呼び出しに遅延があることです。これは、ok アクションが fckEditor.getValue() がデータを取得するために必要なアクションよりも高速であるためです。 fckEditor でテキストをすばやく変更して okBtn を押しても、変更が反映されません。
私はこの解決策を思いついた、
okBtn.addEventListener(Events.ON_CLICK, new EventListener()
{
@Override
public void onEvent(final Event arg0) throws Exception
{
String currentValue;
synchronized (fckEditor)
{
currentValue = fckEditor.getValue();
fckEditor.wait(100);
}
html.setContent(currentValue);
}
});
.wait(100);
ただし、遅延をハードコーディングしており、コンピューターによって遅延が異なる可能性があるため、これが最適なソリューションであると完全には確信していません。そのため、最終的に他の環境では多少の遅延が必要になる可能性があります。
fckEditor.getValue();
呼び出しが完全に終了するまで実行を待機させるにはどうすればよいですか? 正しい文字列を保持してcurrentValue
適切に保存できますか?
ありがとうございました