Comments (7)
Not exactly. What I want is to capture a specific key, say .
, and move to the next input after .
.
However, using this code:
A:onKey(function(self, event, key)
if key == 46 then
B:setFocus()
end
end)
ends up with the dot in B. Again, the problem is not that the output does or doesn't go to A. The problem is that the output goes to B:
Clip.onKey.2.mp4
The output I expected was "This is a sentence."
in A, and nothing in B. If the code had a return false
, I would expect the output to be "This is a sentence"
in A, and nothing in B.
The sleep
solution feels... suboptimal. I feel like the output should just not be recasted to B (i.e. instead of outputting to the currently focused object, it should output to the target object of the keypress). More specifically:
- If
return == false
, then no output should be produced in either. - If
return ~= false
, then the output should be produced to A, not to B.
from basalt.
Hello, thank you very much. I understand now why this is happening. Basalt 1.6.3 has the fix for it - i seperated the char events from the key events, this menas you would need to use a :onChar() event instead of :onKey().
If you are curious on how the events work:
I am using the cc:tweaked event "char" for changing the input. The problem here was the key event always happens before the char event, and i decided one time to call both, the key and the char event when someone uses :onKey(f) which means in your case, you click the ".", the key loop runs, you make the b-input to be the focused one, then the char event loop runs and it writes the . into the b-input (because its focused).
from basalt.
Before this gets closed, I would just like to say that you did a awesome job of writing that bug report, and great replies from both of you!
Keep it up, and thanks for submitting the issue.
from basalt.
Hey! This isn't a bug. :setFocus sets the object immediatley as the focused object. The reason why your custom onKey event handler happens before the inputbox's key event handler is because of the following code:
A:onKey(function(self, event, key)
if(key==keys.a)then
return false
end
end)
this code would make it impossible to write "a" into the inputbox. A possibility would be to create a delayed task:
A:onKey(basalt.schedule(function(self, event, key)
sleep(0.1)
B:setFocus()
end)
This code would wait 0.1s before changing the focus.
https://basalt.madefor.cc/#/objects/Basalt/schedule
from basalt.
I'd also be fine with the key not being recorded by any of them. My major problem is that the key 'passes over' to B.
Is there a way to avoid that?
from basalt.
A:onKey(function(self, event, key)
B:setFocus()
return false
end)
This would make it impossible to write into the input "A" - i am not sure if that's what you want.
from basalt.
Just checked. Everything is working as intended now!
Thank you for the quick fix, and thank you for the compliment! I'm using basalt for a personal project, so expect to hear from me again! Cheers
from basalt.
Related Issues (20)
- bug: `Input` doesn't reset the cursor position after getting emptied by `setValue` HOT 2
- bug: scrolling `Frame` does not account for extended `Dropdown` HOT 1
- bug: DEV branch; basalt.debug crashes when called inside a thread HOT 4
- bug: Setting high ZIndex for parent after adding children overshadows interactions with said children HOT 3
- feature: Return true errors upon failure on `basalt.autoUpdate` HOT 1
- bug: gps.locate() doesn't return anything HOT 2
- feature: Better image handling HOT 1
- bug: XML number buttons crash Basalt HOT 1
- [bug] `Too long without yielding` when downloading basalt on slow internet connection. HOT 3
- bug: `addLine` skips the first line, even if it's empty HOT 4
- bug: Side-specific border coloring with .xml values does not work HOT 1
- bug: long text on button overflows the button's bounding box HOT 1
- feature: prioritize active dropdown boxes if they are in the same Z-Index HOT 2
- feature: Move The Examples From Frame To A Seperate Area For Examples HOT 2
- bug: animation `:wait` doesn't work with 'built-in' animations HOT 4
- feature: fill in both sides of the border (i.e. the full box) when a frame becomes 1-wide HOT 1
- docs: Latest 1.7 docs suggests their is a `Basalt.setTheme()` HOT 2
- bug: [1.7] Button Click events seems to produce a table instead of a string HOT 3
- bug: Broken basalt.update() HOT 1
- bug: installer errors HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basalt.