0

Disable default behaviour for the key strokes that listbox responds in zk(Ex:up and down)

asked 2015-07-12 08:42:34 +0800

Rao gravatar image Rao
3 2

Lisbox in zk by default answers keystrokes like page up and page down, up and down keys and home and end keys. Ex: I want the currently selected row to come down when user hits down arrow. I gave all above keys in ctrlKeys attribute, to call the backend bean when specific keys are hit. But it doesn't call for above keys. It calls back end bean for keys like "delete". I want to disable the default behaviour for above keys for listbox in zk. Kindly help me. This is the ctrlKeys attribute I gave, ctrlKeys="#home#end#del#up#down#pgup#pgdn" onCtrlKey="@command('answerKeyStroke',keyCode=event.getKeyCode(), id=0)"

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-07-12 13:54:48 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Rao,

You can use the following example in order to capture the key event, and then you can add your own logic:

<?page title="Auto Generated index.zul"?>
<window title="Hello World!!" border="normal" width="200px">

<label value="You are using: ${desktop.webApp.version}"/>

<zk xmlns:w="client">

    <listbox >
     <attribute w:name="_doKeyDown"><![CDATA[

            function (evt) {

                var keyCode = evt.keyCode;
                if (keyCode != 38 && keyCode != 40) {
                    this.$_doKeyDown(evt);

                }
            }
        ]]></attribute>
    <listhead>
        <listheader label="col 1" sort="auto" />
        <listheader label="col 2" sort="auto" />
    </listhead>
    <listitem>
        <listcell label="1.1" />
        <listcell label="1.2" />
    </listitem>
    <listitem>
        <listcell label="2.1" />
        <listcell label="2.2" />
    </listitem>
</listbox>


</zk>
</window>

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-07-16 05:21:11 +0800

Rao gravatar image Rao
3 2

Hey Darksu,

That worked like a charm.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-07-12 08:42:34 +0800

Seen: 16 times

Last updated: Jul 16 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More