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