nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Some metrics improvement and cleaning
[nit.git]
/
lib
/
sdl.nit
diff --git
a/lib/sdl.nit
b/lib/sdl.nit
index
41ddc5b
..
6de6d2d
100644
(file)
--- a/
lib/sdl.nit
+++ b/
lib/sdl.nit
@@
-181,6
+181,12
@@
extern class SDLDisplay `{SDL_Surface *`}
fun ignore_mouse_motion_events=(val: Bool) `{
SDL_EventState(SDL_MOUSEMOTION, val? SDL_IGNORE: SDL_ENABLE);
`}
fun ignore_mouse_motion_events=(val: Bool) `{
SDL_EventState(SDL_MOUSEMOTION, val? SDL_IGNORE: SDL_ENABLE);
`}
+
+ # Does `self` has the mouse focus?
+ fun mouse_focus: Bool `{ return SDL_GetAppState() & SDL_APPMOUSEFOCUS; `}
+
+ # Does `self` has the input focus?
+ fun input_focus: Bool `{ return SDL_GetAppState() & SDL_APPINPUTFOCUS; `}
end
# Basic Drawing figures
end
# Basic Drawing figures
@@
-369,27
+375,27
@@
class SDLKeyEvent
super KeyEvent
super SDLInputEvent
super KeyEvent
super SDLInputEvent
- var key_name: String
+ redef var name
var down: Bool
init (key_name: String, down: Bool)
do
var down: Bool
init (key_name: String, down: Bool)
do
- self.key_name = key_name
+ self.name = key_name
self.down = down
end
redef fun to_c: nullable Char
do
self.down = down
end
redef fun to_c: nullable Char
do
- if key_name.length == 1 then return key_name.chars.first
+ if name.length == 1 then return name.chars.first
return null
end
redef fun to_s
do
if down then
return null
end
redef fun to_s
do
if down then
- return "KeyboardEvent key {key_name} down"
+ return "KeyboardEvent key {name} down"
else
else
- return "KeyboardEvent key {key_name} up"
+ return "KeyboardEvent key {name} up"
end
end
end
end
@@
-397,13
+403,13
@@
class SDLKeyEvent
redef fun is_down do return down
# Return true if the key is the up arrow
redef fun is_down do return down
# Return true if the key is the up arrow
- redef fun is_arrow_up do return key_name == "up"
+ redef fun is_arrow_up do return name == "up"
# Return true if the key is the left arrow
# Return true if the key is the left arrow
- redef fun is_arrow_left do return key_name == "left"
+ redef fun is_arrow_left do return name == "left"
# Return true if the key is the down arrow
# Return true if the key is the down arrow
- redef fun is_arrow_down do return key_name == "down"
+ redef fun is_arrow_down do return name == "down"
# Return true if the key is the right arrow
# Return true if the key is the right arrow
- redef fun is_arrow_right do return key_name == "right"
+ redef fun is_arrow_right do return name == "right"
end
class SDLQuitEvent
end
class SDLQuitEvent