1

ZSS - Undo/redo functionality

asked 2011-05-23 23:37:26 +0800

hverma gravatar image hverma
22 1

I am new to zk and want to implement the spreadsheet like features in my statement:

1) Un-limited Undo's
2) arrow keyboard navigations
3) re-sizable columns
4)freeze columns
5)copy-paste

I tried looking up samples and have following sample code:

index.zul

<window apply="org.zkdemo.controller.SpreadSheetDemoComposer">

<spreadsheet id="balance" src="/SpreadSheetDemo.xls" maxrows="20"
maxcolumns="20" height="600px" width="800px" ctrlKeys="^c^v^x^z^y" />
<menupopup id="cellMenu">
<menuitem id="cutMenu" label="Cut" />
<menuitem id="copyMenu" label="Copy" />
<menuitem id="pasteMenu" label="Paste" />
<menuitem id="undoMenu" label="Undo"/>
<menuitem id="redoMenu" label="Redo"/>
</menupopup>
</window>

Java Class contain following related methods:

public void onClick$undoMenu(){
onUndo();
}

public void onClick$redoMenu(){
onRedo();
}

/**
* Execute cut copy or paste using key control
* @param evt
*/
public void onCtrlKey$balance(KeyEvent evt) {
if (evt.isCtrlKey()) {
switch (evt.getKeyCode()) {
case 'C':
onCopy();
break;
case 'V':
onPaste();
break;
case 'X':
onCut();
break;
case 'Z':
onUndo();
break;
case 'Y':
onRedo();
break;
}

}
}

private void onUndo(){
// What should i write here to get the undo feature implemented.
System.out.println("UNDOooo");
}

private void onRedo(){
// What should i write here to get the redo feature implemented.
System.out.println("Redooo");
}

Please provide the valuable inputs. Thanks !

delete flag offensive retag edit
Be the first one to reply this discussion!
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

RSS

Stats

Asked: 2011-05-23 23:37:26 +0800

Seen: 235 times

Last updated: May 23 '11

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