You can use the pastebin http://paste.factorcode.org/ to share with the
list. Most of the other resources are blog posts, maybe you can get your
vocab featured in someone's blog if you don't have one ?

For the right click, you did what I had in mind. You could have used
"set-gestures" instead of "define-command-map", because the command-maps
only add documentation (with $command and $command-map) on top of gestures.

As for the bikeshed, In row-hook, you can remove the "dup ... swap" by
using "keep" to minimize stack shuffling.

Overall it's nicely readable.
Cheers,
Jon



Jon


On Thu, Nov 14, 2013 at 10:04 PM, <bidon12...@free.fr> wrote:

> Hi All,
>
> here is some code I am sharing as I think it might be useful to other
> beginners.
>
> This snippet shows :
>
> 1) my attempt at following Jon's hint regarding removing the right-click
> action on a table row.
>
> 2) how to change the data that is displayed. Look in row-hook, the main
> word is set-control-value.
>
> To run the code, you can copy and paste in the factor window, and then
> type sgui2 at the repl.
>
> Is there a more appropriate location to share these snippets ?
>
> Cheers,
>
> Manuel
>
> ! ---------------------------------------
> USING: accessors colors.constants kernel math math.parser
> math.ranges models sequences ui ui.commands ui.gadgets
> ui.gadgets.scrollers ui.gadgets.tables ui.gestures ;
>
> IN: sgui2
>
> TUPLE: no-rc-table < table ;
>
> ! this prevents the show-table-menu action on right-click : "no right-click
> table"
> no-rc-table "row" f {
>     { T{ button-down f f 3 } drop }
> } define-command-map
>
> SINGLETON: seq-renderer
>
> M: seq-renderer filled-column drop 0 ;
> M: seq-renderer column-titles drop { "Value" } ;
> M: seq-renderer row-columns drop number>string { } 1sequence ;
> M: seq-renderer row-color 2drop "blue" named-color ;
> M: seq-renderer row-value drop ;
>
> : init-range ( -- range )
>     0 19 [a,b] ;
>
> : new-range ( value -- range )
>     dup 19 + [a,b] ;
>
> : row-hook ( gadget -- )
>     dup selected-row [ new-range ] [ drop init-range ] if
>     swap set-control-value ;
>
> : <sgui2> ( -- table )
>     init-range <model>
>     seq-renderer
>     no-rc-table new-table
>         8 >>gap
>         COLOR: dark-gray >>column-line-color
>         { 200 400 } >>pref-dim
>         [ row-hook ] >>hook ;
>
>  MAIN-WINDOW: sgui2 { { title "Simple GUI 2" } } <sgui2> <scroller>
> >>gadgets ;
> ! ---------------------------------------
>
>
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to