mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Fix HTML5 button
This commit is contained in:
parent
628723386e
commit
37fff52aa5
@ -465,8 +465,6 @@ The API section now filled with overview and usage examples. I've started with t
|
|||||||
|
|
||||||
Also, I've added the **Unit Tests**. It's not cover all **Druid** code, but it's a good start! 🎉
|
Also, I've added the **Unit Tests**. It's not cover all **Druid** code, but it's a good start! 🎉
|
||||||
|
|
||||||
I have the feedback form for you, please fill it if you have a free minute. It will help me to improve **Druid** in future. %LINK HERE%
|
|
||||||
|
|
||||||
Have a good day!
|
Have a good day!
|
||||||
|
|
||||||
|
|
||||||
@ -478,7 +476,7 @@ Have a good day!
|
|||||||
- **#39**: [System] Finally add **Unit Tests**. Yeah, it cover not all **Druid** code, but it's a good start! 🎉
|
- **#39**: [System] Finally add **Unit Tests**. Yeah, it cover not all **Druid** code, but it's a good start! 🎉
|
||||||
- **#219**: [System] UTF-8 performance optimization. Now Druid will try to use *utf8* native extension over lua utf8 library if exists. If you wanna use native utf8, just [add the extension](https://github.com/d954mas/defold-utf8) in your `game.project` dependency.
|
- **#219**: [System] UTF-8 performance optimization. Now Druid will try to use *utf8* native extension over lua utf8 library if exists. If you wanna use native utf8, just [add the extension](https://github.com/d954mas/defold-utf8) in your `game.project` dependency.
|
||||||
- **#156**: [Button] Now button can work in HTML5 with `html5.set_interaction_listener`.
|
- **#156**: [Button] Now button can work in HTML5 with `html5.set_interaction_listener`.
|
||||||
- The API is `button:set_html5_user_interaction(true)`. In HTML5 mode button have several restrictions. Basically, only the single tap event will work.
|
- The API is `button:set_web_user_interaction(true)`. In HTML5 mode button have several restrictions. Basically, only the single tap event will work.
|
||||||
- **#227**: Update current URL in HTML5 example
|
- **#227**: Update current URL in HTML5 example
|
||||||
- Now if you will open the example from direct URL, it will be updated to the current URL in your browser. So now it's much easier to share the example link with each other.
|
- Now if you will open the example from direct URL, it will be updated to the current URL in your browser. So now it's much easier to share the example link with each other.
|
||||||
- **#183**: Documentation about [GUI in World Space](https://forum.defold.com/t/how-to-gui-in-defold/73256#gui-in-world-coordinates-49)
|
- **#183**: Documentation about [GUI in World Space](https://forum.defold.com/t/how-to-gui-in-defold/73256#gui-in-world-coordinates-49)
|
||||||
|
@ -168,6 +168,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function on_button_click(self)
|
local function on_button_click(self)
|
||||||
|
if self._is_html5_mode then
|
||||||
|
self._is_html5_listener_set = false
|
||||||
|
html5.set_interaction_listener(nil)
|
||||||
|
end
|
||||||
self.click_in_row = 1
|
self.click_in_row = 1
|
||||||
self.on_click:trigger(self:get_context(), self.params, self)
|
self.on_click:trigger(self:get_context(), self.params, self)
|
||||||
self.style.on_click(self, self.anim_node)
|
self.style.on_click(self, self.anim_node)
|
||||||
@ -302,6 +306,8 @@ function Button.init(self, node, callback, custom_args, anim_node)
|
|||||||
|
|
||||||
self._check_function = nil
|
self._check_function = nil
|
||||||
self._failure_callback = nil
|
self._failure_callback = nil
|
||||||
|
self._is_html5_mode = false
|
||||||
|
self._is_html5_listener_set = false
|
||||||
|
|
||||||
-- Events
|
-- Events
|
||||||
self.on_click = Event(callback)
|
self.on_click = Event(callback)
|
||||||
@ -349,7 +355,9 @@ function Button.on_input(self, action_id, action)
|
|||||||
if action.released then
|
if action.released then
|
||||||
self.on_click_outside:trigger(self:get_context(), self.params, self)
|
self.on_click_outside:trigger(self:get_context(), self.params, self)
|
||||||
end
|
end
|
||||||
if self._is_html5_mode then
|
|
||||||
|
if self._is_html5_mode and self._is_html5_listener_set then
|
||||||
|
self._is_html5_listener_set = false
|
||||||
html5.set_interaction_listener(nil)
|
html5.set_interaction_listener(nil)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -367,9 +375,9 @@ function Button.on_input(self, action_id, action)
|
|||||||
self.on_pressed:trigger(self:get_context(), self.params, self)
|
self.on_pressed:trigger(self:get_context(), self.params, self)
|
||||||
|
|
||||||
if self._is_html5_mode then
|
if self._is_html5_mode then
|
||||||
|
self._is_html5_listener_set = true
|
||||||
html5.set_interaction_listener(function()
|
html5.set_interaction_listener(function()
|
||||||
on_button_click(self)
|
on_button_click(self)
|
||||||
html5.set_interaction_listener(nil)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -528,7 +536,7 @@ end
|
|||||||
-- @usage
|
-- @usage
|
||||||
-- button:set_web_user_interaction(true)
|
-- button:set_web_user_interaction(true)
|
||||||
function Button.set_web_user_interaction(self, is_web_mode)
|
function Button.set_web_user_interaction(self, is_web_mode)
|
||||||
self._is_html5_mode = is_web_mode and html5
|
self._is_html5_mode = not not (is_web_mode and html5)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ function Input.init(self, click_node, text_node, keyboard_type)
|
|||||||
self.button.on_long_click:subscribe(clear_and_select)
|
self.button.on_long_click:subscribe(clear_and_select)
|
||||||
|
|
||||||
if html5 then
|
if html5 then
|
||||||
self.button:set_html5_user_interaction(true)
|
self.button:set_web_user_interaction(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.on_input_select = Event()
|
self.on_input_select = Event()
|
||||||
|
@ -53,7 +53,6 @@ function init(self)
|
|||||||
|
|
||||||
self.druid:new_button("button_add_first/button", on_add_first)
|
self.druid:new_button("button_add_first/button", on_add_first)
|
||||||
local button = self.druid:new_button("button_add_last/button", on_add_last)
|
local button = self.druid:new_button("button_add_last/button", on_add_last)
|
||||||
button:set_html5_user_interaction(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user