britzl / gooey Goto Github PK
View Code? Open in Web Editor NEWDefold GUI system
License: MIT License
Defold GUI system
License: MIT License
I just started playing around with this library recently (using release 7.5.2), am currently trying to incorporate a basic text input node in my project (on android). For some reason though, on the final touch frame, the 'released_now' and 'clickable' fields that would indicate a completed click do not show up.
Here's the relevant portion of console feedback: (pprinting the input table each frame)
DEBUG:SCRIPT:
{ --[[0xad34a090]]
pressed_now = false,
node = @(0, -24, 0),
long_pressed = true,
current_text = "",
set_visible = function: 0xad34a180,
refresh_fn = function: 0xaed03a10,
marked_text = "",
out_now = false,
total_width = 0,
set_long_pressed_time = function: 0xaed057d0,
text_width = 0,
long_pressed_time = 1.5,
marked_text_width = 0,
clicked = false,
enabled = true,
set_text = function: 0xad34a100,
text = "",
consumed = false,
refresh = function: 0xad34a140,
over = false,
empty = true,
deselected_now = false,
over_now = false,
keyboard_type = 0,
released_now = false
}
DEBUG:SCRIPT:
{ --[[0xad34a090]]
pressed_now = false,
node = @(0, -24, 0),
long_pressed = true,
current_text = "",
set_visible = function: 0xad34a180,
refresh_fn = function: 0xaed03a10,
marked_text = "",
out_now = false,
total_width = 0,
set_long_pressed_time = function: 0xaed057d0,
text_width = 0,
long_pressed_time = 1.5,
marked_text_width = 0,
clicked = false,
enabled = true,
set_text = function: 0xad34a100,
text = "",
consumed = false,
refresh = function: 0xad34a140,
over = false,
empty = true,
deselected_now = false,
over_now = false,
keyboard_type = 0,
released_now = false
}
DEBUG:SCRIPT:
{ --[[0xad34a090]]
pressed_now = false,
node = @(0, -24, 0),
long_pressed = true,
current_text = "",
set_visible = function: 0xad34a180,
refresh_fn = function: 0xaed03a10,
marked_text = "",
out_now = false,
total_width = 0,
set_long_pressed_time = function: 0xaed057d0,
text_width = 0,
long_pressed_time = 1.5,
marked_text_width = 0,
enabled = true,
set_text = function: 0xad34a100,
text = "",
refresh = function: 0xad34a140,
over = false,
empty = true,
deselected_now = false,
over_now = false,
keyboard_type = 0
}
I'm kind of surprised nobody else has had this issue, as it's a pretty big roadblock for me. It's possible I'm doing something wrong but I don't know what that would be. Can anyone else replicate this issue?
From example:
STATE
It is possible to set the state of a checkbox. This is good for setting the initial state of the checkbox:
update_checkbox(gooey.checkbox("checkbox/bg").set_checked(true))
update_checkbox(gooey.checkbox("checkbox/bg").set_visible(false))
but is not available right now. We should return instance to make it work.
It seems we should modify core.instance method:
for name,fn in pairs(functions or {}) do
data[name] = function(...)
fn(data, ...)
+++
return data
+++
end
end
Hello!
So in 9.1.4 everything work as expected, but from 10.0.0 it looks like the dynamic lists are not updating list elements according to refresh function. First observation is that list.pressed_now / over_item_now / over_item are always false, regardless if I really point at the node. Tested on examples provided with Gooey. I see there were some breaking changes in 10.0.0, but can't correlate quickly as of now.
The dynamic list component is initialized with an empty vector3 and only updated on scrolling. Using the dynamic list scroll value to update a scrollbar makes it be "bottomed out".
The bottom of the scroll list looks like this when not resizing
But if I resize the screen with defos.set_window_size(0, 0, 570, 1224)
(from 720, 1280) it looks like this instead
Quite a lot of padding is added and a extra item can be seen. The data is nil (but it get's set even though I check for nil before doing gui.set_text()
.
The stencil node have Adjustment Mode: Stretch and Y Anchor: Top
Hej! Is dynamic list data dynamic? Can I add items to the list dynamically? Or do I need to set the number of list elements once and then I cannot change it? :)
Selecting areas of text box with click drag or holding shift plus arrow keys
I'm looking at the examples, kenneyblue to be specific.
on_input
contains all the theme specific updates for the buttons, checkboxes etc.
Looking at the theme's file's specific fucntions, the M.button returns the gooey.button call.
I'm adopting this style into a theme of my own, where I have a custom type of buttons. When pressing on (pressed_now == true
) and fully qualified 'clicks' I want to consume the input.
Reason being that I want interaction on my buttons to take priority and not allow my game area to react to that input. Only on 'accidental' interactions, like releasing on top of the button but not having done the initial press - a non fully qualified click so to say.
My initial thought was to - inside the gui_scripts on_input
- save a boolean result for all calls to the theme button function. Then check if any of those were true to know whether or not input should be consumed or not.
At this point I'm thinking I might be doing things wrong, it seems a bit unwieldy. Is there a recommended way for handling input consumption with gooey?
If you do 1.23
it will/might automatically expand into 1.11.23
Here are some other examples
123.45
-> 123.123123.45
123.ab
-> 123.33.ab
ab.123
-> ab.123
.
-> .
It feels like it start doing odd stuff as soon as there is a . and some recommended/auto correction text.
It should be possible to easily set the initial checked/unchecked state of a checkbox or the selected radiobutton of group.
Here's a wishlist I made for another UI project but some may be useful for this one too.
If you click on an item and scroll the list you don't expect the item to be clicked.
Would like a way to change the scrolling speed. Maybe by passing a multiplier or something.
Implement the ability to "flick" scroll list. After a fast swipe the list should keep its momentum
Right now if you start typing and press left/right cursor buttons it will print ~
sign
On iOS devices I get missed backspace presses in input fields, as the ones on the examples.
If I type "123" using the on-screen keyboard then click backspace two times the resulting text can be either "1", "12" or "123".
Devices: iPad 2018 and iPhone 8
OS: iOS 14.4
Browsers: Safari and Chrome
This would enable to user to have a dynamic scrollbar handle. Making it possible to have big handles that can been seen in for example web browser
There should be a setable option/flag that specifies, if the scroll down with mouse wheel should move the horizontal list's items from left->right or right->left.
I face to problem that it could not detect a reload in core.instance
function.
You can reproduce the problem by scene reloading in example project.
I think it is because __dm_script_instance__
has been removed in Defold 1.2.151.
ref: Defold Forum
Lines 110 to 117 in 8705121
Currently, I added temporary reset function in my local and call this for detecting a reload of gui script.
Happens when you do gooey.dynamic_list(...)
before gooey.vertical_scrollbar(...)
in on_input(..)
or init(...)
(as if you use update_list(gooey.dynamic_list(...))
on init(...)
)
dynamic_list
will call update_list
before gooey.vertical_scrollbar(...)
so action will always have been nil.
Workaround is to pass the expected variables in init(...)
before update_list
like gooey.vertical_scrollbar("scrollbar/handle", "scrollbar/bar", nil, {x=0, y=0})
Easily reproduced with a emoji such as 😄 while typing on a phone.
@britzl How do you think we should handle this?
ERROR:SCRIPT: /gooey/internal/utf8.lua:128: Invalid UTF-8 character
stack traceback:
[C]: in function 'error'
/gooey/internal/utf8.lua:128: in function 'utf8charbytes'
/gooey/internal/utf8.lua:190: in function 'utf8len'
/gooey/internal/utf8.lua:207: in function 'sub'
/gooey/internal/input.lua:168: in function 'input'
/gooey/gooey.lua:162: in function 'input'
/screens/change_pokemon/edit/edit.gui_script:150: in function </screens/change_pokemon/edit/edit.gui_script:146>
Usage
gooey.input("text_field", gui.KEYBOARD_TYPE_DEFAULT, action_id, action, {max_length = 10, allowed_characters="%a"})
When i was scrolling the gooey dynamic list, text variables are scrolled successfully but the images not scrolled successfully.
Discussion link in Forum - https://forum.defold.com/t/dynamic-list-image-not-change/48883.
The text input field currently has no notion of cursor position. It always adds/removes text from the end of the entered text.
Because of this early bail:
-- bail early if the list is empty
if list.data_size == 0 then
if refresh_fn then refresh_fn(list) end
return list
end
...
update_dynamic_listitem_data(list)
When the list had items but then became empty, item.data
for items that previously had data stays what it was before.
Hi,
I have a working project using gooey GUI with a single button.
I would like to use the gooey-dirtylarry theme for example. I added the following dependencies in my game.project file :
https://github.com/britzl/gooey/archive/master.zip
https://github.com/britzl/gooey-dirtylarry/archive/main.zip
So, if I replaced the line :
local gooey = require "gooey.gooey"
by this line :
local gooey = require "gooey.themes.dirtylarry.dirtylarry"
(because my assumption is : this is the same interface for acquire_input and button functions between the genuine gooey interface and the dirtylarry gooey theme interface...)
when I execute my code, I got this error :
/example/menu.gui_script
The file '/gooey/themes/dirtylarry/dirtylarry.lua' could not be found.
What is my mistake ?
Thanks for your help...
Line 60 in 3ab5b02
for example: if we have such struct as:
Node1 (enabled) => Node2 (disabled) => Button(enabled)
and check is_enabled(Button) we got enabled of Node1 - true
Update the example/demo apps so that users can see the cool new features!
http://britzl.github.io/Gooey
https://www.defold.com/community/projects/79521/
Limit number of characters for input boxes.
At function M.input(node_id, keyboard_type, action_id, action)
add additional optional parameter like
function M.input(node_id, keyboard_type, action_id, action, max_text_width)
and then in code just check if this parameter is set, don't add new characters to string
I'm not getting any keyboard showing up when clicking the text input fields on the Gooey demo.
If I go to the home screen and back to the browser with the text field already selected, the keyboard will pop up but the text field doesn't respond to any typing. Could it be that some android update has broken something?
Device: Galaxy S10E
OS: Android 11
Browser: Chrome and Firefox
Keyboard: Samsung default and Microsoft Swiftkey
Making a note here for a todo for me to make these themes. defold-dark replicate the general look of editor 2's colors and style, gooey to be a theme which looks appropriate fit in theme for the gooey logo.
Hi Britzl,
it seems, there is a bug in Gooey:
In master/gooey/internal/input.lua, line 37, you use:
function M.utf8_gfind(text)
return text:gfind("([%z\1-\127\194-\244][\128-\191]*)")
end
That seems to be deprecated and causes an error.
I assume, it should be replaced by:
function M.utf8_gfind(text)
return text:gmatch("([%z\1-\127\194-\244][\128-\191]*)")
end
Regards,
Lutz
Setting the text using gui.set_text() will be replaced the next time the input field is updated. Perhaps detect when gui.set_text() has been done?
(Like your nice button https://github.com/britzl/defold-input/blob/master/in/button.lua)
To enable the user to create components dynamically
for i=1, 10 do
local clone = gui.clone(gui.get_node("template_node/root"))
gooey.checkbox(clone["template_node/root"], action_id, action, on_checked, update_checkboxd)
end
With max_length = 8
you can only have 4 "å". Expected is of course to be able have 8
My Galaxy S7 is on Android 7.0.
Trying the example project in the repo, using kenneyblue, and testing the input.
When focusing on the input text, my phone's keyboard pops up. Writing text works fine. When pressing the backspace button on the keyboard, I have to hold it down to make it remove characters. A single tap on backspace does not register "long enough" for it to remove any text.
Reproduce:
Expected:
Actual:
Have a new interesting error, i use a gooey dynamic_list with x number of item rows in it, i want to find out on what element inside one list item i have clicked on, for example a delete button, so i use
if gui.pick_node(list.items[list.selected_item].nodes[hash(“giftitem/delete_btn”)], action.x, action.y)
inside the gooey dynamic_list function, and it works fine for item 1 to 9, but number 10 and above fails, and it looks like it is the .nodes that doesnt work when i debug printed out them like you se in the picture here
i made an example based on the gooey example project, and maybe the errors are coming as soon as i scroll the list and try to click on an scene object in one list item. So in the project i include it looks like it start failing on item nr 6
local function input_callback(input)
if input.pressed_now then
gui.set_color(input.node, dcolors.palette.c2)
elseif input.deselected_now then
gui.set_color(input.node, dcolors.palette.c3)
end
end
Input widget's input.deselected_now
property is always false. Tested by selecting the widget, entering text, then deselecting the widget. Input bindings match Gooey's expectations correctly.
On line 136 of /gooey/internal/input.lua, local deselected_now = false
is never referenced again, so it is never changed to true.
Reported by forum user Febuse:
There are a few bugs in the gooey kenney implementation: go in kenney mode, write some text, select something in the list and a radio button, mark the checkbox, hit back, enter kenney mode again, it looks like it was unchanged, move mouse, everything reverts to how you left it. The textfield also seems to only trigger from the middle and on mobile browser it needs 2 clicks on the textfield: one to make blinking cursor and one to show the keyboard. After that the keyboard needs to be manually closed even if the focus would no longer be on the textfield (click button).
Add support for horizontally scrolling lists
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.