Thread Rating:
  • 177 Vote(s) - 2.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RecordGridのセルでEnterキーを押下したときにフォーカス移動
03-05-2015, 07:53 PM,
#1
RecordGridのセルでEnterキーを押下したときにフォーカス移動
RecordGridのセルでEnterキーを押下したとき、Tabキーを押下した際と同じようにフォーカスを移動させたいです。
上記実現する方法をご教示ください。

※下記拝見しましたが、解決には至っていないようでした。
  念のためリンクを貼らせていただきます。
Enterキーでのフォーカス遷移
http://communities.curl.com/showthread.php?tid=168
Reply
03-06-2015, 10:17 AM,
#2
RE: RecordGridのセルでEnterキーを押下したときにフォーカス移動
こんなんでどうでしょうか。

Code:
{define-class public EnterKeyCell {inherits StandardStringCell}
  
  {constructor public {default}
    {construct-super}
  }
  
  {method public {create-editor}:TextField
    let editor:TextField = {super.create-editor}
    {editor.ui-object.add-event-handler
        {on e:KeyPress do
            {if e.value == KeyPressValue.enter then
                def shift? = e.shift?
                {after 0s do
                    {self.grid.ui.traverse forward? = not shift?}
                }
                {e.consume}
            }
        }
    }
    {return editor}
  }
}

{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},
        {RecordData First = "Ben", Last = "Abrams", Age = 24},
        {RecordData First = "Sam", Last = "Jones", Age = 30},
        {RecordData First = "Nigel", Last = "Stevens", Age = 32},
        {RecordData First = "Bert", Last = "Stevens", Age = 26}
    }
}

{let rv:RecordView =
    {RecordView
        people
    }
}

{let rg:RecordGrid =
    {RecordGrid
        record-source = rv,
        cell-spec = EnterKeyCell,

        {RecordGridColumn "First"}
    }
}

{value
    {VBox
        rg,
        {CommandButton
            label = "append record",
            {on Action do
                {people.append {RecordData}}
            }
        }
    }
}
Reply
03-06-2015, 10:41 AM,
#3
RE: RecordGridのセルでEnterキーを押下したときにフォーカス移動
上記ソースで実現できました。
ありがとうございます。
Reply

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('1210')