-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on #383 - keypress/keyup/keydown events
* not working yet since there can be slot handlers and they need to be sent to non-native widget (svg,plot,image...) Much like click does * Just checking in the code.
- Loading branch information
Cecil
committed
Dec 10, 2017
1 parent
4ac54ab
commit bdc03c0
Showing
6 changed files
with
139 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Shoes.app do | ||
|
||
event do |evt| | ||
# do not trigger new events here unless you can handle them recursively | ||
# which is harder than you think. | ||
case evt.type | ||
when :click | ||
$stderr.puts "click handler called: #{evt.type} #{evt.button}, #{evt.x} #{evt.y} #{evt.modifiers}" | ||
evt.accept = true | ||
when :keypress | ||
$stderr.puts "keypress: #{evt.key}" | ||
evt.accept = true | ||
when :keydown | ||
$stderr.puts "keydown for #{evt.key}" | ||
evt.accept = $ck.checked? | ||
when :keyup | ||
$stderr.puts "keyup for #{evt.key}" | ||
evt.accept = $ck.checked? | ||
else | ||
puts "Other: #{evt.type.inspect}" | ||
evt.accept = true | ||
end | ||
end | ||
|
||
stack do | ||
para "Key Tests" | ||
flow do | ||
$ck = check checked: true; para "Enable up/down" | ||
end | ||
@eb = edit_box width: 500, height: 350 | ||
end | ||
keypress do |key| | ||
@eb.append "press: #{key}\n" | ||
end | ||
keyup do |key| | ||
@eb.append "up: #{key}\n" | ||
end | ||
keydown do |key| | ||
@eb.append "down: #{key}\n" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters