Thread Rating:
  • 315 Vote(s) - 2.62 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ご質問
08-24-2011, 07:32 PM,
#1
ご質問
こんばんは。sakumaです。

また質問させてください。

Enterキーで縦方向にカーソル移動させる事は、実装できますでしょうか?

ご回答頂ければ幸いです。よろしくお願いいたします。
08-25-2011, 08:53 AM,
#2
RE: ご質問
単純なコントロール間の移動なら、Enterキーでフォーカス移動するイベントと
フォーカスの移動順序を設定するだけなので
そんなに難しくなく実現できると思います。

ただ、RecordGrid上でそのような動きをするのは
少し難しいかと思います。
08-25-2011, 10:22 AM, (This post was last modified: 08-25-2011, 10:32 AM by Yuhki.)
#3
RE: ご質問
すこし強引ですが、以下でどうでしょうか。
不具合がでる可能性がありましたらどなたかご指摘願います。

以下で問題なければ実現できます。

Code:
{define-class public open CustomCell {inherits StandardStringCell}
  
  {constructor public {default}}

  {method public {create-editor}:TextField
    def tf = {super.create-editor}
    {tf.add-event-handler
        {on ev:KeyPress at tf:TextField do
            {if ev.value == KeyPressValue.enter then
                def kp = {KeyPress}
                set kp.value =
                    {if ev.shift? then
                        KeyPressValue.up
                     else
                        KeyPressValue.down
                    }
                {self.handle-event kp}
            }
        }
    }
    {return tf}
  }
}
08-25-2011, 02:01 PM,
#4
RE: ご質問
質問の意図とは外れるかもしれませんが・・・

RecordGrid では、レコードセレクタ上の
Enter キー押下のイベントが KeyPress ではなく
Action に置き換わってしまいますが、

GuiManager クラスを使うことで回避は可能です。

意図したイベントが置き換わってしまい、ハンドリングできないときの
手段として、自分は使っていました。

以下はグリットのレコードセレクタ上でのダブルクリックと
エンターを区別させたい場合のサンプルです。

Code:
{define-enum public event-type
    KeyPress,
    PointerPress
}
{let press-type:event-type = event-type.KeyPress}
{let gm:GuiManager = {get-gui-manager}}
{gm.add-event-handler
    {on e:Event at an:any do
        {type-switch e
         case rkp:RawKeyPress do
            set press-type = event-type.KeyPress
         case pp:PointerPress do
            set press-type = event-type.PointerPress
        }}}

{define-class public GridDoubleClick {inherits Event}
  {constructor public {default}}
}
{define-class public GridEnter {inherits Event}
  {constructor public {default}}
}

{define-class public CustomRecordGrid {inherits RecordGrid}
  let public ge:GridDoubleClick = {GridDoubleClick.default}
  let public ge2:GridEnter = {GridEnter.default}
  field private _my-event:EventHandler = {on e:Action at grid:RecordGrid do
                                   {if grid.current-index >= 0 then
                                       {if event-type.PointerPress == press-type then
                                           {grid.enqueue-event CustomRecordGrid.ge}
                                        elseif event-type.KeyPress == press-type then
                                           {grid.enqueue-event CustomRecordGrid.ge2}
                                       }
                                   }
                                 }

  {constructor public {default ...}
    {construct-super ...}
    {self.add-event-handler
        self._my-event}
  }
}
{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField
                "First", caption = "First Name", domain = String
            },
            {RecordField
                "Last", caption = "Last Name", domain = String
            },
            {RecordField "Age", domain = int}
        },
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}
{CustomRecordGrid
    record-source = people,
    height = 3cm,
    {on GridEnter do
        {popup-message "GridEnter!"}
    },
    {on GridDoubleClick do
        {popup-message "GridDoubleClick!"}
    }
}

Forum Jump:


Users browsing this thread:
1 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('233')