lib/window.rb in gglib-1.2.1 vs lib/window.rb in gglib-1.3.0
- old
+ new
@@ -217,11 +217,11 @@
@leftdrag.start
@focused.event
elsif id==Gosu::Button::MsRight
@rightdrag.start
@focused.event
- elsif char!=nil
+ elsif char!=nil and @stickfocused.acceptText?
if button_down?(Gosu::Button::KbLeftShift) or button_down?(Gosu::Button::KbRightShift)
if char=~/[A-Z]/i
char=char.upcase!
else
capschar=WidgetTextCaps[char]
@@ -229,17 +229,19 @@
char=capschar
end
end
end
@stickfocused.feedText(char)
- end
+ else
+ @stickfocused.event(Widget::Event::KeyDown, id)
+ end
end
if @focused!=nil and not @focused.sleeping? and (@stickfocused==nil or @focused.id != @stickfocused.id) #normally focused widgets only recieve click input
if id==Gosu::Button::MsLeft
- @focused.downevent(WidgetEvent::MsLeft)
+ @focused.downevent(Widget::Event::MsLeft)
elsif id==Gosu::Button::MsRight
- @focused.downevent(WidgetEvent::MsRight)
+ @focused.downevent(Widget::Event::MsRight)
end
end
end
def widgetUpProc(id)
@@ -247,59 +249,33 @@
setStickyFocus(nil) if (id==Gosu::Button::MsLeft or id==Gosu::Button::MsRight) and @stickfocused!=nil #and not @stickfocused.contains?(mouse_x, mouse_y)
if @stickfocused!=nil and not @stickfocused.sleeping? #only sticky focused widgets recieve text input
if id==Gosu::Button::MsLeft
if @leftdrag.inprogress
@leftdrag.end
- @stickfocused.event(WidgetEvent::MsLeftDrag)
+ @stickfocused.event(Widget::Event::MsLeftDrag)
else
@leftdrag.terminate
- @stickfocused.event(WidgetEvent::MsLeft)
+ @stickfocused.event(Widget::Event::MsLeft)
end
elsif id==Gosu::Button::MsRight
if @rightdrag.inprogress
@rightdrag.end
- @stickfocused.event(WidgetEvent::MsRightDrag)
+ @stickfocused.event(Widget::Event::MsRightDrag)
else
@rightdrag.terminate
- @stickfocused.event(WidgetEvent::MsRight)
+ @stickfocused.event(Widget::Event::MsRight)
end
- elsif id==Gosu::Button::KbUp or id==Gosu::Button::GpUp
- @stickfocused.event(WidgetEvent::KeyUp)
- elsif id==Gosu::Button::KbDown or id==Gosu::Button::GpDown
- @stickfocused.event(WidgetEvent::KeyDown)
- elsif id==Gosu::Button::KbLeft or id==Gosu::Button::GpLeft
- @stickfocused.event(WidgetEvent::KeyLeft)
- elsif id==Gosu::Button::KbRight or id==Gosu::Button::GpRight
- @stickfocused.event(WidgetEvent::KeyRight)
- elsif id==Gosu::Button::KbRight or id==Gosu::Button::GpRight
- @stickfocused.event(WidgetEvent::KeyRight)
- elsif id==Gosu::Button::KbBackspace or id==Gosu::Button::KbDelete
- @stickfocused.event(WidgetEvent::KeyDelete)
- elsif id==Gosu::Button::KbEscape or id==Gosu::Button::GpButton7
- @stickfocused.event(WidgetEvent::KeyEscape)
- elsif id==Gosu::Button::KbEnter or id==Gosu::Button::GpButton2 or id==28 #strange Gosu bug, KbEnter!=Enter code
- @stickfocused.event(WidgetEvent::KeyEnter)
- elsif id==Gosu::Button::KbLeftAlt or id==Gosu::Button::KbRightAlt or id==Gosu::Button::GpButton5
- @stickfocused.event(WidgetEvent::KeyAlt)
- elsif id==Gosu::Button::KbLeftControl or id==Gosu::Button::KbRightControl or id==Gosu::Button::GpButton3
- @stickfocused.event(WidgetEvent::KeyControl)
- elsif id==Gosu::Button::KbLeftShift or id==Gosu::Button::KbRightShift or id==Gosu::Button::GpButton6
- @stickfocused.event(WidgetEvent::KeyShift)
- elsif id==Gosu::Button::KbSpace or id==Gosu::Button::KbSpace or id==Gosu::Button::GpButton4
- @stickfocused.event(WidgetEvent::KeySpace)
- elsif id==Gosu::Button::GpButton0
- @stickfocused.event(WidgetEvent::GpEnter)
- elsif id==Gosu::Button::GpButton1
- @stickfocused.event(WidgetEvent::GpCancel)
+ else
+ @stickfocused.event(Widget::Event::KeyUp, id)
end
end
if @focused!=nil and not @focused.sleeping? and (@stickfocused==nil or @focused.id != @stickfocused.id) #normally focused widgets only recieve click input
if id==Gosu::Button::MsLeft
- @focused.event(WidgetEvent::MsLeft)
+ @focused.event(Widget::Event::MsLeft)
elsif id==Gosu::Button::MsRight
- @focused.event(WidgetEvent::MsRight)
+ @focused.event(Widget::Event::MsRight)
elsif id==Gosu::Button::GpButton0
- @focused.event(WidgetEvent::GpEnter)
+ @focused.event(Widget::Event::GpEnter)
end
end
end
def checkFocus