Thread Rating:
  • 528 Vote(s) - 2.83 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ハイライト表示時のTextFieldを書き換える
01-20-2012, 10:46 PM,
#1
ハイライト表示時のTextFieldを書き換える
下記URL
http://developers.curlap.com/faq/48-faq-...36-19.html
を参考に、次のコードにて全角および半角のカンマを入力できないようなTextFieldを作成しましたが、
ハイライト表示の状態でTextFieldの値を書き換えると、文字列が入れ替わらず、追記になってしまいますが、
これを回避する方法はありますか?
操作手順
1.全角で「123,456」を入力すると、値には「123456」が入ります
2.次に、123456の後ろに「789」を入力すると、値には「123456789」が入ります
3.次に、「123456789」をハイライト表示させたあと、「987,654」を入力すると、
期待する動作は「987654」ですが、実際は「123456789987654」になってしまいます。
Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}
{applet
    {compiler-directives careful? = true}
}
{import * from CURL.LANGUAGE.REGEXP}{let start:Frame = {Frame color = "blue", font-weight = "bold"}}
{let change:Frame = {Frame font-weight = "bold" }}
{let end:Frame = {Frame color = "blue", font-weight = "bold"}}
{let result:Frame = {Frame color = "red", font-weight = "bold"}}
{let vl:Frame = {Frame font-weight = "bold"}}{let tf:TextField =
    {TextField width = 5cm,
        input-method-focus-behavior = "activate",
        ui-object = {SkinnableTextFieldUI
                        {on e:StartCompositionEvent do
                            {start.clear}
                            {change.clear}
                            {end.clear}
                            {result.clear}
                            {vl.clear}
                            {start.add replace? = true, "イベントが開始しました"}
                        },
                        {on e:CompositionChangeEvent do
                            {change.add replace? = true, e.string}
                        },
                        {on e:EndCompositionEvent do
                            {end.add replace? = true, "イベントが終了しました"}
                        },
                        {on e:CompositionResultEvent do
                            let valuestr:#String = tf.value
                            let str:String = e.string
                            set str =
                                {regexp-subst ",",
                                    str,
                                    "",
                                    replace-all?=true
                                }
                            set tf.value = valuestr & str
                            {result.add replace? = true, tf.value}
                            let ev:ValueChanged = {ValueChanged}
                            {tf.enqueue-event ev}
                            {e.consume}
                        },
                        {on e:KeyPress do
                            {if  e.value == '\u002C' then
                                {e.consume}
                            }
                        }
                    },
        {on e:ValueChanged do
            {vl.add replace? = true, tf.value}
        }
    }}{VBox
    tf,
    {Table columns = 2,
        "イベントの開始", start,
        "入力中の文字列", change,
        "イベントの終了", end,
        "入力結果", result,
        "値", vl
    }
}


Messages In This Thread
ハイライト表示時のTextFieldを書き換える - by usami - 01-20-2012, 10:46 PM
Forum Jump:


Users browsing this thread:
2 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('395')