mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Update docs, wrong links
This commit is contained in:
parent
807168d850
commit
7aa2da11f6
@ -4,7 +4,7 @@
|
||||
[](https://github.com/sponsors/insality) [](https://ko-fi.com/insality) [](https://www.buymeacoffee.com/insality)
|
||||
|
||||
[](https://github.com/Insality/druid/releases)
|
||||
[](https://github.com/Insality/druid/actions)
|
||||
[](https://github.com/Insality/druid/actions)
|
||||
[](https://codecov.io/gh/Insality/druid)
|
||||
|
||||
**Druid** - powerful Defold component UI library. Use basic and extended **Druid** components or make your own game-specific components to make amazing GUI in your games.
|
||||
@ -185,11 +185,11 @@ end
|
||||
|
||||
```
|
||||
|
||||
For all **Druid** instance functions, [see here](https://insality.github.io/druid/modules/druid_instance.html).
|
||||
For all **Druid** instance functions, [see here](https://insality.github.io/druid/modules/DruidInstance.html).
|
||||
|
||||
## Druid Events
|
||||
|
||||
Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/druid_event.html). In component API ([button example](https://insality.github.io/druid/modules/druid.button.html#Events)) pointed list of component events. You can manually subscribe to those events with the following API:
|
||||
Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/DruidEvent.html). In component API ([button example](https://insality.github.io/druid/modules/Button.html#on_click)) pointed list of component events. You can manually subscribe to those events with the following API:
|
||||
|
||||
- **event:subscribe**(callback)
|
||||
|
||||
|
@ -6,7 +6,7 @@ Druid allows you to create your custom components which contains your custom log
|
||||
|
||||
I wanna make a point that Druid is not only set of defined components to place buttons, scroll, etc. But mostly it's a way how to handle all your GUI elements in general. Custom components is most powerful way to separate logic and make higher abstraction in your code.
|
||||
|
||||
Every component is the children of Basic Druid component. Read the [basic component API here].(https://insality.github.io/druid/modules/component.html), Methods of basic components you can call via `self:{method_name}`
|
||||
Every component is the children of Basic Druid component. Read the [basic component API here](https://insality.github.io/druid/modules/BaseComponent.html), Methods of basic components you can call via `self:{method_name}`
|
||||
|
||||
|
||||
## Custom components
|
||||
@ -172,16 +172,16 @@ The generator script also check current GUI scene for Druid components to make s
|
||||
Start your node names with one of next keyword to say parser make component stubs for your. For example for nodes `button` and `button_exit` will be generated two Druid Button components with callback stubs.
|
||||
|
||||
Available keywords:
|
||||
- `button` - add [Druid Button](docs_md/01-components.md#button) and generate callback stub
|
||||
- `text` - add [Druid Text](docs_md/01-components.md#text)
|
||||
- `lang_text` - add Druid [Druid Lang Text](docs_md/01-components.md#lang-text)
|
||||
- `grid` or `static_grid` - add Druid [Druid Static Grid](docs_md/01-components.md#static-grid). You should to setup Grid prefab for this component after file generation
|
||||
- `dynamic_grid` - add Druid [Druid Dynamic Grid](docs_md/01-components.md#dynamic-grid)
|
||||
- `scroll_view` - add [Druid Scroll](docs_md/01-components.md#scroll). It will add `scroll_content` node with the same postfix too. Check that is will correct node
|
||||
- `blocker` - add [Druid Blocker](docs_md/01-components.md#blocker)
|
||||
- `slider` - add [Druid Slider](docs_md/01-components.md#slider). You should to adjust end position of Slider after file generation
|
||||
- `progress` - add [Druid Progress](docs_md/01-components.md#progress)
|
||||
- `timer` - add [Druid Timer](docs_md/01-components.md#timer)
|
||||
- `button` - add [Druid Button](01-components.md#button) and generate callback stub
|
||||
- `text` - add [Druid Text](01-components.md#text)
|
||||
- `lang_text` - add Druid [Druid Lang Text](01-components.md#lang-text)
|
||||
- `grid` or `static_grid` - add Druid [Druid Static Grid](01-components.md#static-grid). You should to setup Grid prefab for this component after file generation
|
||||
- `dynamic_grid` - add Druid [Druid Dynamic Grid](01-components.md#dynamic-grid)
|
||||
- `scroll_view` - add [Druid Scroll](01-components.md#scroll). It will add `scroll_content` node with the same postfix too. Check that is will correct node
|
||||
- `blocker` - add [Druid Blocker](01-components.md#blocker)
|
||||
- `slider` - add [Druid Slider](01-components.md#slider). You should to adjust end position of Slider after file generation
|
||||
- `progress` - add [Druid Progress](01-components.md#progress)
|
||||
- `timer` - add [Druid Timer](01-components.md#timer)
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
---On click outside of button(self, params, button_instance)
|
||||
-- @tfield DruidEvent on_click_outside @{DruidEvent}
|
||||
|
||||
---On pressed button callback(self, params, button_instance)
|
||||
-- @tfield DruidEvent on_pressed @{DruidEvent}
|
||||
|
||||
---Trigger node
|
||||
-- @tfield node node
|
||||
|
||||
@ -141,7 +144,7 @@ local function on_button_release(self)
|
||||
end
|
||||
return true
|
||||
else
|
||||
if self.can_action then
|
||||
if self.can_action and not self._is_html5_mode then
|
||||
self.can_action = false
|
||||
|
||||
local time = socket.gettime()
|
||||
@ -221,6 +224,7 @@ function Button.init(self, node, callback, params, anim_node)
|
||||
|
||||
-- Event stubs
|
||||
self.on_click = Event(callback)
|
||||
self.on_pressed = Event()
|
||||
self.on_repeated_click = Event()
|
||||
self.on_long_click = Event()
|
||||
self.on_double_click = Event()
|
||||
@ -267,6 +271,9 @@ function Button.on_input(self, action_id, action)
|
||||
if action.released then
|
||||
self.on_click_outside:trigger(self:get_context(), self.params, self)
|
||||
end
|
||||
if self._is_html5_mode then
|
||||
html5.set_interaction_listener(nil)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@ -279,6 +286,14 @@ function Button.on_input(self, action_id, action)
|
||||
self.can_action = true
|
||||
self.is_repeated_started = false
|
||||
self.last_pressed_time = socket.gettime()
|
||||
self.on_pressed:trigger(self:get_context(), self.params, self)
|
||||
|
||||
if self._is_html5_mode then
|
||||
html5.set_interaction_listener(function()
|
||||
on_button_click(self)
|
||||
html5.set_interaction_listener(nil)
|
||||
end)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@ -406,4 +421,16 @@ function Button.set_check_function(self, check_function, failure_callback)
|
||||
end
|
||||
|
||||
|
||||
--- Set buttom click mode to call itself inside html5 callback in user interaction event
|
||||
-- It required to do protected stuff like copy/paste text, show html keyboard, etc
|
||||
-- The HTML5 button don't call any events except on_click
|
||||
-- @tparam Button self
|
||||
-- @tparam[opt] boolean is_html_mode If true - button will be called inside html5 callback
|
||||
-- @treturn Button Current button instance
|
||||
function Button.set_html5_user_interaction(self, is_html_mode)
|
||||
self._is_html5_mode = is_html_mode and html5
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return Button
|
||||
|
Loading…
x
Reference in New Issue
Block a user