Paste: Trying to add / remove buttons in grid
Author: | Marcel |
Mode: | factor |
Date: | Thu, 2 Apr 2009 14:24:56 |
Plain Text |
USING: arrays kernel namespaces ui ui.gadgets.buttons
ui.gadgets.grids ui.tools.listener ;
IN: sokoban
SYMBOL: canvas
DEFER: button-42
: button-2 ( -- ) canvas get 1 0 grid-remove "2" [ drop [ button-42 ] call-listener ] <bevel-button> 1 0 grid-add drop ;
: button-42 ( -- ) canvas get 1 0 grid-remove "42" [ drop [ button-2 ] call-listener ] <bevel-button> 1 0 grid-add drop ;
: <sokoban-runner> ( -- gadget )
"1" [ ] <bevel-button> "2" [ drop [ button-42 ] call-listener ] <bevel-button> 2array
"3" [ ] <bevel-button> "4" [ ] <bevel-button> 2array
2array <grid> ;
: start-sokoban ( -- ) [ <sokoban-runner> dup canvas set "Sokoban" open-window ] with-ui ;
MAIN: start-sokoban
Author: | Marcel |
Mode: | factor |
Date: | Thu, 2 Apr 2009 15:11:25 |
Plain Text |
USING: arrays kernel namespaces ui ui.gadgets.buttons
ui.gadgets.grids ui.tools.listener locals ;
IN: sokoban
:: button-2 ( canvas -- ) canvas 1 0 grid-remove drop ;
:: <sokoban-runner> ( canvas -- gadget )
"1" [ ] <bevel-button> "2" [ drop [ canvas button-2 ] call ] <bevel-button> 2array
"3" [ ] <bevel-button> "4" [ ] <bevel-button> 2array
2array canvas new-grid ;
: start-sokoban ( -- ) [ grid <sokoban-runner> "Sokoban" open-window ] with-ui ;
MAIN: start-sokoban
New Annotation