Skip to content

Commit

Permalink
mail-ui: Add support for "tabbing" between UI elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Apr 17, 2011
1 parent 9b6f6e5 commit c56a0f1
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions mail-ui/mail-ui.factor
@@ -1,13 +1,40 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: accessors arrays colors colors.constants kernel smtp ui
USING: accessors arrays colors.constants kernel smtp ui
ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.buttons
ui.gadgets.editors ui.gadgets.labels ui.gadgets.scrollers
ui.gadgets.tracks ui.pens.solid ;
ui.gadgets.tracks ui.gestures ui.pens.solid ;

IN: mail-ui

<PRIVATE

TUPLE: tabbing-editor < editor next-editor prev-editor ;

: <tabbing-editor> ( -- editor )
tabbing-editor new-editor ;

TUPLE: tabbing-multiline-editor < multiline-editor next-editor prev-editor ;

: <tabbing-multiline-editor> ( -- editor )
tabbing-multiline-editor new-editor ;

: com-prev ( editor -- )
prev-editor>> [ request-focus ] when* ;

: com-next ( editor -- )
next-editor>> [ request-focus ] when* ;

tabbing-editor tabbing-multiline-editor [
"editing" f {
{ T{ key-down f f "TAB" } com-next }
{ T{ key-down f { S+ } "TAB" } com-prev }
} define-command-map
] bi@

PRIVATE>

TUPLE: mail-gadget < track to subject body ;

M: mail-gadget focusable-child* to>> ;
Expand Down Expand Up @@ -41,13 +68,21 @@ mail-gadget "toolbar" f {
1 >>fill
{ 10 10 } >>gap

<editor> >>to
<editor> >>subject
<multiline-editor>
<tabbing-editor> >>to
<tabbing-editor> >>subject
<tabbing-multiline-editor>
10 >>min-rows
60 >>min-cols
>>body

dup to>> over subject>> >>next-editor drop
dup to>> over body>> >>prev-editor drop

dup subject>> over body>> >>next-editor drop
dup subject>> over to>> >>prev-editor drop

dup body>> over subject>> >>prev-editor drop

dup <to> f track-add
dup <subject> f track-add
dup <body> 1 track-add
Expand Down

0 comments on commit c56a0f1

Please sign in to comment.