rename on-input -> on-activate
it's only called when RET is pressed, not during editing
This commit is contained in:
parent
28080a1387
commit
fb834f496c
@ -87,7 +87,7 @@
|
||||
state)
|
||||
)))
|
||||
|
||||
(fn on-input [self str]
|
||||
(fn on-activate [self str]
|
||||
(let [s (next-action self.state str)
|
||||
param (if s.active (. (. s.command :params) s.this-param))]
|
||||
(set self.state s)
|
||||
@ -121,7 +121,7 @@
|
||||
:collected-params supplied-params
|
||||
}]
|
||||
(set self.state s)
|
||||
(let [r (self:on-input nil)]
|
||||
(let [r (self:on-activate nil)]
|
||||
(update-widget-state self r)
|
||||
(self.entry:grab_focus)
|
||||
r)))
|
||||
@ -136,7 +136,7 @@
|
||||
:state default-state
|
||||
: activate
|
||||
:active? (fn [self] self.state.active)
|
||||
: on-input
|
||||
: on-activate
|
||||
: invoke-interactively
|
||||
: entry
|
||||
:widget box
|
||||
@ -147,7 +147,7 @@
|
||||
(box:pack_start entry true true 5)
|
||||
(tset entry :on_activate
|
||||
(fn [event]
|
||||
(let [result (self:on-input event.text)]
|
||||
(let [result (self:on-activate event.text)]
|
||||
(set prompt.label (or result.prompt ""))
|
||||
(set entry.sensitive result.active)
|
||||
(set entry.text (or result.default result.error "")))))
|
||||
|
@ -20,7 +20,7 @@
|
||||
(let [commander (Command.commander)
|
||||
(ok err)
|
||||
(match-try (commander:activate)
|
||||
{:active true} (commander:on-input "not-a-command")
|
||||
{:active true} (commander:on-activate "not-a-command")
|
||||
(where {:error e :active false} (e:match "can't find command")) true
|
||||
(catch
|
||||
x (values nil (view x))))]
|
||||
@ -30,9 +30,9 @@
|
||||
(let [commander (Command.commander)
|
||||
(ok err)
|
||||
(match-try (commander:activate)
|
||||
{:active true} (commander:on-input "multiply")
|
||||
{:active true :prompt p1} (commander:on-input "2")
|
||||
{:active true :prompt p2} (commander:on-input "3")
|
||||
{:active true} (commander:on-activate "multiply")
|
||||
{:active true :prompt p1} (commander:on-activate "2")
|
||||
{:active true :prompt p2} (commander:on-activate "3")
|
||||
(where {:active false} (= happened 6)) true
|
||||
(catch
|
||||
x (values nil (view x))))]
|
||||
|
Loading…
Reference in New Issue
Block a user