Class: Scarpe::WebviewSubscriptionItem
- Inherits:
-
WebviewWidget
- Object
- Shoes::Linkable
- WebviewWidget
- Scarpe::WebviewSubscriptionItem
- Defined in:
- lib/scarpe/wv/subscription_item.rb
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from WebviewWidget
#children, #parent, #shoes_linkable_id
Attributes inherited from Shoes::Linkable
Instance Method Summary collapse
- #destroy_self ⇒ Object
- #element ⇒ Object
-
#initialize(properties) ⇒ WebviewSubscriptionItem
constructor
A new instance of WebviewSubscriptionItem.
-
#set_parent(new_parent) ⇒ Object
This will get called once we know the parent, which is useful for events like hover, where our subscription is likely to depend on what our parent is.
Methods inherited from WebviewWidget
#add_child, #bind, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #style, #to_html
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::Linkable
#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event
Constructor Details
#initialize(properties) ⇒ WebviewSubscriptionItem
Returns a new instance of WebviewSubscriptionItem.
4 5 6 7 8 9 10 |
# File 'lib/scarpe/wv/subscription_item.rb', line 4 def initialize(properties) super bind(@shoes_api_name) do |*args| send_self_event(*args, event_name: @shoes_api_name) end end |
Instance Method Details
#destroy_self ⇒ Object
46 47 48 49 |
# File 'lib/scarpe/wv/subscription_item.rb', line 46 def destroy_self @parent.remove_event_callbacks(self) super end |
#element ⇒ Object
12 13 14 |
# File 'lib/scarpe/wv/subscription_item.rb', line 12 def element "" end |
#set_parent(new_parent) ⇒ Object
This will get called once we know the parent, which is useful for events like hover, where our subscription is likely to depend on what our parent is.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scarpe/wv/subscription_item.rb', line 18 def set_parent(new_parent) super case @shoes_api_name when "motion" # TODO: what do we do for whole-screen mousemove outside the window? # Those should be set on body, which right now doesn't have a widget. # TODO: figure out how to handle alt and meta keys - does Shoes3 recognise those? new_parent.set_event_callback( self, "onmousemove", handler_js_code( @shoes_api_name, "arguments[0].x", "arguments[0].y", "arguments[0].ctrlKey", "arguments[0].shiftKey", ), ) when "hover" new_parent.set_event_callback(self, "onmouseenter", handler_js_code(@shoes_api_name)) when "click" new_parent.set_event_callback(self, "onclick", handler_js_code(@shoes_api_name, "arguments[0].button", "arguments[0].x", "arguments[0].y")) else raise "Unknown Shoes event API: #{@shoes_api_name}!" end end |