Creating a Command History

kerry.kim.russo's Avatar

kerry.kim.russo

05 Dec, 2012 08:38 PM

Hey All,

Doing a sanity check of sorts.

I am writing a tiny application to get a better feel for things and one of the features I have is a command history. In my application, a click triggers a command but that command may not always affect the model. In my command, inside the exec() method, the model is only updated if a condition is true. Currently, if the condition is true, the command dispatches an event which tells the application to store the Command in it's history.

Is that an acceptable way of creating a command history of ONLY commands that have actually changed the model? Anyone have other ways they've done it in the past?

  1. Support Staff 1 Posted by Ondina D.F. on 06 Dec, 2012 10:43 AM

    Ondina D.F.'s Avatar

    Hey Kerry :)
    Please take a look at this:
    https://github.com/timoxley/robotlegs-utilities-UndoableCommand
    and tell us if that's what you're after.
    Ondina

  2. 2 Posted by kerry.kim.russo on 06 Dec, 2012 04:38 PM

    kerry.kim.russo's Avatar

    Something like that. Actually, I'm sure that would've been the better/easier option.

    From the sounds of it, the command history utility has the functionality I need to selectively add commands to a history (by way of the cancel method). This is how I'm doing things, except I'm dispatching an event from the command if it is to be added to the command history. I didn't look into how the utility does the adding part yet.

  3. Ondina D.F. closed this discussion on 20 Dec, 2012 12:43 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac