]> gitweb.factorcode.org Git - factor.git/commitdiff
manual models for alert buttons
authorSam Anklesaria <sam@Tintin.local>
Tue, 19 May 2009 21:40:39 +0000 (16:40 -0500)
committerSam Anklesaria <sam@Tintin.local>
Tue, 19 May 2009 21:40:39 +0000 (16:40 -0500)
extra/ui/frp/frp.factor
extra/ui/gadgets/alerts/alerts.factor

index f59361a0ec284ffba624e827e2fbe0aea33ccc76..459d52983fbb2ada6deadcd0bb8de7312881a24b 100644 (file)
@@ -77,9 +77,10 @@ M: frp-product model-activated dup model-changed ;
 
 ! Gadgets
 TUPLE: frp-button < button hook ;
-: <frp-button> ( text -- button ) [ [ t swap set-control-value ] keep
-   dup hook>> [ call( button -- ) ] [ drop ] if* ]
-   frp-button new-button border-button-theme f <basic> >>model ;
+: <frp-button> ( text -- button ) [
+      [ t swap set-control-value ] keep
+      dup hook>> [ call( button -- ) ] [ drop ] if*
+   ] frp-button new-button border-button-theme f <basic> >>model ;
 
 TUPLE: frp-table < table { quot initial: [ ] } { val-quot initial: [ ] } color-quot column-titles column-alignment ;
 M: frp-table column-titles column-titles>> ;
index 0c4a4fbd67de726acfb5984945b949dfeb70ffb4..8cb6a3fd086122f948aaeae751a0ffc1a6ef592a 100644 (file)
@@ -1,15 +1,18 @@
-USING: accessors kernel ui ui.frp ui.gadgets ui.gadgets.labels
-ui.gadgets.buttons ui.gadgets.packs locals sequences fonts io.styles ;
+USING: accessors models kernel ui ui.frp ui.gadgets ui.gadgets.labels
+ui.gadgets.editors ui.gadgets.buttons ui.gadgets.packs
+locals sequences fonts io.styles ;
 
 IN: ui.gadgets.alerts
 :: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align
    string <label> T{ font { name "sans-serif" } { size 18 } } >>font { 200 100 } >>pref-dim add-gadget 
    "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;
 
-: ask-user ( string -- model )
-   [ [let | lbl  [ <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , ]
+:: ask-user* ( model string -- model' )
+   [ [let | lbl  [ string <label>  T{ font { name "sans-serif" } { size 14 } } >>font dup , ]
             fldm [ <frp-field> ->% 1 ]
-            btn  [ "okay" <frp-button> ] |
+            btn  [ "okay" <frp-button> model >>model ] |
          btn -> [ fldm swap <updates> ]
                 [ [ drop lbl close-window ] <$ , ] bi
-   ] ] <vbox> { 161 86 } >>pref-dim "" open-window ;
\ No newline at end of file
+   ] ] <vbox> { 161 86 } >>pref-dim "" open-window ;
+
+: ask-user ( string -- model ) f <model> swap ask-user* ;
\ No newline at end of file