Skip to content

Commit

Permalink
enable shift key detection in action_event
Browse files Browse the repository at this point in the history
  • Loading branch information
tex committed Feb 2, 2012
1 parent 2591d3d commit 912e910
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/wf.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
-record(function, {?ACTION_BASE(action_function), function }).
-record(set, {?ACTION_BASE(action_set), value}).
-record(redirect, {?ACTION_BASE(action_redirect), url}).
-record(event, {?ACTION_BASE(action_event), type=default, keycode=undefined, delay=0, postback, validation_group, delegate, extra_param}).
-record(event, {?ACTION_BASE(action_event), type=default, keycode=undefined, shift_key=false, delay=0, postback, validation_group, delegate, extra_param}).
-record(validate, {?ACTION_BASE(action_validate), on=submit, success_text=" ", group, validators, attach_to }).
-record(validation_error, {?ACTION_BASE(action_validation_error), text="" }).
-record(alert, {?ACTION_BASE(action_alert), text=""}).
Expand Down
6 changes: 3 additions & 3 deletions src/actions/action_event.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
render_action(#event {
postback=Postback, actions=Actions,
anchor=Anchor, trigger=Trigger, target=Target, validation_group=ValidationGroup,
type=Type, keycode=KeyCode, delay=Delay, delegate=Delegate,
type=Type, keycode=KeyCode, shift_key=ShiftKey, delay=Delay, delegate=Delegate,
extra_param=ExtraParam
}) ->

Expand Down Expand Up @@ -43,7 +43,7 @@ render_action(#event {
_ when (Type==keypress orelse Type==keydown orelse Type==keyup) andalso (KeyCode /= undefined) ->
[
wf:f("Nitrogen.$observe_event('~s', '~s', '~s', function anonymous(event) {", [Anchor, Trigger, Type]),
wf:f("if (Nitrogen.$is_key_code(event, ~p)) { ", [KeyCode]),
wf:f("if (Nitrogen.$is_key_code(event, ~p, ~p)) { ", [KeyCode, ShiftKey]),
AnchorScript, PostbackScript, WireAction,
"return false; }});"
];
Expand All @@ -52,7 +52,7 @@ render_action(#event {
enterkey ->
[
wf:f("Nitrogen.$observe_event('~s', '~s', '~s', function anonymous(event) {", [Anchor, Trigger, keydown]),
wf:f("if (Nitrogen.$is_key_code(event, ~p)) { ", [13]),
wf:f("if (Nitrogen.$is_key_code(event, ~p, ~p)) { ", [13, ShiftKey]),
AnchorScript, PostbackScript, WireAction,
"return false; }});"
];
Expand Down
4 changes: 2 additions & 2 deletions www/nitrogen.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ NitrogenClass.prototype.$return_false = function(value, args) {
return false;
}

NitrogenClass.prototype.$is_key_code = function(event, keyCode) {
return (event && event.keyCode == keyCode);
NitrogenClass.prototype.$is_key_code = function(event, keyCode, shiftKey) {
return (event && event.keyCode == keyCode && event.shiftKey == shiftKey);
}

NitrogenClass.prototype.$go_next = function(controlID) {
Expand Down

0 comments on commit 912e910

Please sign in to comment.