PointerEnvelope からなら取得できるようですね。
Code:
{let people:RecordSet =
{RecordSet
{RecordFields
{RecordField "First", domain = String},
{RecordField "Last", 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}
}
}
||ダブルクリックイベント
{define-class public ReocrdDoubleClick {inherits Event}
field public grid:RecordGrid
field public record:Record
field public cell:RecordGridCell
{constructor public {default
grid:RecordGrid,
record:Record,
cell:RecordGridCell
}
set self.record = record
set self.grid = grid
set self.cell = cell
}
}
{define-class public CustomRecordGrid {inherits RecordGrid}
{constructor public {default ...}
{construct-super{splice ...}}
||ダブルクリックイベント
{self.add-event-handler
||通常の PointerPress では取得できないので
||PointerEnvelopeEvent.contents から取得する
{on e:PointerEnvelopeEvent do
{type-switch e.contents
case pp:PointerPress do
{if pp.click-count == 2 and pp.button == 1 then
||ダブルクリックされた場所が、レコード(セル)上であることを確認
let (cell:#RecordGridCell, index:int) = {self.grid-objects-at e.x, e.y}
{if-non-null cell then
{if index >= 0 then
def ev = {ReocrdDoubleClick self, self.records[index], cell}
{self.handle-event ev}
}
}
}
}
}
}
}
}
{value
{CustomRecordGrid
grid-line-color = "#ccccff",
horizontal-grid-line-width = 6px,
vertical-grid-line-width = 6px,
record-source = people,
||ダブルクリックしたら、そのレコードの情報を表示する
{on e:ReocrdDoubleClick do
def rfs = e.grid.records.fields
def tbl = {Table columns = rfs.size}
{for rf in rfs do
{tbl.add rf.name}
}
{for rf in rfs do
{tbl.add e.record[rf.name]}
}
let str:String = "クリックされたセル:" & e.cell.field.name
{popup-message {VBox tbl, str}}
}
}
}