class
UIng::Area::Handler
- UIng::Area::Handler
- Reference
- Object
Overview
Drawing and input callbacks with closure support. Area retains the Handler and its Procs; native UserData points back to it. Keep captured native resources unfreed while callbacks use them. Direct LibUI callers must retain the Handler themselves.
handler = Area::Handler.new do draw { |area, params| puts "Drawing..." } key_event { |area, event| true } # Return true if handled end
Included Modules
- UIng::BlockConstructor
Defined in:
uing/area/handler.crConstant Summary
-
SCROLL_CALLBACK =
->(ah : ::Pointer(LibUI::AreaHandler), area : ::Pointer(LibUI::Area), event : ::Pointer(LibUI::AreaScrollEvent)) : LibC::Int do begin handler = ::Box(Handler).unbox(ah.value.user_data) callback = handler.scroll_event_callback || (return 0) area_wrapper = ((ControlRegistry.lookup(area)).as?(Area)) || (Area.new(area, borrowed: true)) callback.call(area_wrapper, Area::ScrollEvent.new(event)) ? 1 : 0 rescue e UIng.handle_callback_error(e, "Area scroll_event") 0 end end
Constructors
- .new(*args, &)
- .new(*args, **kwargs, &)
-
.new
ameba:disable Metrics/CyclomaticComplexity
Instance Method Summary
- #clear_drag_broken : Nil
- #clear_draw : Nil
- #clear_key_event : Nil
- #clear_mouse_crossed : Nil
- #clear_mouse_event : Nil
- #clear_scroll_event : Nil
- #drag_broken(&block : Area -> Nil)
- #drag_broken(callback : Nil) : Nil
- #draw(&block : Area, Area::Draw::Params -> Nil)
- #draw(callback : Nil) : Nil
- #key_event(&block : Area, Area::KeyEvent -> Bool)
- #key_event(callback : Nil) : Nil
- #mouse_crossed(&block : Area, Bool -> Nil)
- #mouse_crossed(callback : Nil) : Nil
- #mouse_event(&block : Area, Area::MouseEvent -> Nil)
- #mouse_event(callback : Nil) : Nil
-
#scroll_event(&block : Area, Area::ScrollEvent -> Bool)
Receives wheel and trackpad movement.
- #scroll_event(callback : Nil) : Nil
- #to_unsafe
Macros inherited from module UIng::BlockConstructor
block_constructor
block_constructor
Constructor Detail
Instance Method Detail
Receives wheel and trackpad movement. Return true to consume it, or false to allow a scrolling Area to scroll normally.