iface #31
@ -68,8 +68,6 @@ init({Parent, Caller, {Account, J}}) ->
|
||||
AmtTx = wxTextCtrl:new(Panel, ?wxID_ANY),
|
||||
AmtSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Amount")}]),
|
||||
AmtInSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||
AmtLabel = wxStaticText:new(Panel, ?wxID_ANY, "木"),
|
||||
_ = wxStaticBoxSizer:add(AmtInSz, AmtLabel, zxw:flags(base)),
|
||||
_ = wxStaticBoxSizer:add(AmtInSz, AmtTx, zxw:flags({wide, 5})),
|
||||
_ = wxStaticBoxSizer:add(AmtSz, AmtInSz, zxw:flags({wide, 5})),
|
||||
PayloadTx = wxTextCtrl:new(Panel, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]),
|
||||
@ -114,7 +112,7 @@ init({Parent, Caller, {Account, J}}) ->
|
||||
ok = wxBoxSizer:layout(MainSz),
|
||||
ok = wxFrame:centerOnParent(Frame),
|
||||
true = wxFrame:show(Frame),
|
||||
self() ! {tab, cancel},
|
||||
self() ! {focus, to_tx},
|
||||
State =
|
||||
#s{frame = Frame, parent = Parent, caller = Caller,
|
||||
to_tx = ToTx, amount_tx = AmtTx, payload_tx = PayloadTx,
|
||||
@ -133,19 +131,30 @@ key_handler(ToTx, AmtTx, PayloadTx, TTL_Sl, GasSl, Affirm, Cancel) ->
|
||||
AffirmID = wxButton:getId(Affirm),
|
||||
CancelID = wxButton:getId(Cancel),
|
||||
fun(#wx{id = ID, event = #wxKey{type = key_down, keyCode = Code}}, KeyPress) ->
|
||||
case Code of
|
||||
9 ->
|
||||
case {Code, wxKeyEvent:shiftDown(KeyPress)} of
|
||||
{9, false} ->
|
||||
case ID of
|
||||
ToID -> Me ! {tab, to_tx};
|
||||
AmtID -> Me ! {tab, amount_tx};
|
||||
PL_ID -> Me ! {tab, payload_tx};
|
||||
TTL_ID -> Me ! {tab, ttl_sl};
|
||||
GasID -> Me ! {tab, gas_sl};
|
||||
AffirmID -> Me ! {tab, affirm};
|
||||
CancelID -> Me ! {tab, cancel};
|
||||
ToID -> Me ! {focus, amount_tx};
|
||||
AmtID -> Me ! {focus, payload_tx};
|
||||
PL_ID -> Me ! {focus, ttl_sl};
|
||||
TTL_ID -> Me ! {focus, gas_sl};
|
||||
GasID -> Me ! {focus, affirm};
|
||||
AffirmID -> Me ! {focus, cancel};
|
||||
CancelID -> Me ! {focus, to_tx};
|
||||
_ -> wxEvent:skip(KeyPress)
|
||||
end;
|
||||
13 ->
|
||||
{9, true} ->
|
||||
case ID of
|
||||
ToID -> Me ! {focus, cancel};
|
||||
AmtID -> Me ! {focus, to_tx};
|
||||
PL_ID -> Me ! {focus, amount_tx};
|
||||
TTL_ID -> Me ! {focus, payload_tx};
|
||||
GasID -> Me ! {focus, ttl_sl};
|
||||
AffirmID -> Me ! {focus, gas_sl};
|
||||
CancelID -> Me ! {focus, affirm};
|
||||
_ -> wxEvent:skip(KeyPress)
|
||||
end;
|
||||
{13, _} ->
|
||||
case ID of
|
||||
ToID -> Me ! {tab, to_tx};
|
||||
AmtID -> Me ! {tab, amount_tx};
|
||||
@ -156,17 +165,17 @@ key_handler(ToTx, AmtTx, PayloadTx, TTL_Sl, GasSl, Affirm, Cancel) ->
|
||||
CancelID -> Me ! {enter, cancel};
|
||||
_ -> wxEvent:skip(KeyPress)
|
||||
end;
|
||||
27 ->
|
||||
{27, _} ->
|
||||
Me ! esc;
|
||||
_ ->
|
||||
{_, _} ->
|
||||
wxEvent:skip(KeyPress)
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
|
||||
handle_info({tab, Element}, State) ->
|
||||
ok = tab_traverse(Element, State),
|
||||
handle_info({focus, Element}, State) ->
|
||||
ok = focus(Element, State),
|
||||
{noreply, State};
|
||||
handle_info({enter, affirm}, State) ->
|
||||
NewState = check(State),
|
||||
@ -201,20 +210,13 @@ handle_event(Event, State) ->
|
||||
|
||||
%%% Doers
|
||||
|
||||
tab_traverse(to_tx, #s{amount_tx = AmountTX}) ->
|
||||
wxTextCtrl:setFocus(AmountTX);
|
||||
tab_traverse(amount_tx, #s{payload_tx = PayloadTX}) ->
|
||||
wxTextCtrl:setFocus(PayloadTX);
|
||||
tab_traverse(payload_tx, #s{ttl_sl = TTL_SL}) ->
|
||||
wxSlider:setFocus(TTL_SL);
|
||||
tab_traverse(ttl_sl, #s{gas_sl = GasSL}) ->
|
||||
wxSlider:setFocus(GasSL);
|
||||
tab_traverse(gas_sl, #s{affirm = Affirm}) ->
|
||||
wxButton:setFocus(Affirm);
|
||||
tab_traverse(affirm, #s{cancel = Cancel}) ->
|
||||
wxButton:setFocus(Cancel);
|
||||
tab_traverse(cancel, #s{to_tx = ToTX}) ->
|
||||
wxTextCtrl:setFocus(ToTX).
|
||||
focus(to_tx, #s{to_tx = ToTX}) -> wxTextCtrl:setFocus(ToTX);
|
||||
focus(amount_tx, #s{amount_tx = AmountTX}) -> wxTextCtrl:setFocus(AmountTX);
|
||||
focus(payload_tx, #s{payload_tx = PayloadTX}) -> wxTextCtrl:setFocus(PayloadTX);
|
||||
focus(ttl_sl, #s{ttl_sl = TTL_SL}) -> wxSlider:setFocus(TTL_SL);
|
||||
focus(gas_sl, #s{gas_sl = GasSL}) -> wxSlider:setFocus(GasSL);
|
||||
focus(affirm, #s{affirm = Affirm}) -> wxButton:setFocus(Affirm);
|
||||
focus(cancel, #s{cancel = Cancel}) -> wxButton:setFocus(Cancel).
|
||||
|
||||
|
||||
cancel(#s{frame = Frame, caller = Caller}) ->
|
||||
@ -266,7 +268,7 @@ clean_spend([{gas_price, GasPrice} | Rest], TX, J, Errors) ->
|
||||
clean_spend(Rest, TX#spend_tx{gas_price = GasPrice}, J, Errors);
|
||||
clean_spend([{ttl, TTL} | Rest], TX, J, Errors) ->
|
||||
clean_spend(Rest, TX#spend_tx{ttl = TTL}, J, Errors);
|
||||
clean_spend([{payload = S} | Rest], TX, J, Errors) ->
|
||||
clean_spend([{payload, S} | Rest], TX, J, Errors) ->
|
||||
clean_spend(Rest, TX#spend_tx{payload = list_to_binary(S)}, J, Errors);
|
||||
clean_spend([], TX, _, []) ->
|
||||
{ok, TX};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user