Thread Rating:
  • 315 Vote(s) - 2.62 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ご質問
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!"}
    }
}


Messages In This Thread
ご質問 - by sakuma - 08-24-2011, 07:32 PM
RE: ご質問 - by nmyzk - 08-25-2011, 08:53 AM
RE: ご質問 - by Yuhki - 08-25-2011, 10:22 AM
RE: ご質問 - by onyo - 08-25-2011, 02:01 PM
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')