Page 1 of 1
Ruby: how to force editbox to close?
Posted: Mon Feb 16, 2015 7:38 pm
by KG_is_back
Here is the thing... I what to use editbox to detect keyboard input and string pasting - to detect last tiped character / pasted string. Only way I know how to do that is to create new empty editbox, every time the content changes. However, it is not possible to create new edit box while an existing edit box is active. Is there a way to force edit box to close from inside ruby? AFAIK, it closes only when tab/enter is pressed or you click away.
Re: Ruby: how to force editbox to close?
Posted: Mon Feb 16, 2015 11:23 pm
by Exo
I don't know how it can be close via code.
Only other thing I can think may be of some use is the "isKeyPressed()" method to detect when keys are pressed,but it is not really suitable for this task I don't think.
Re: Ruby: how to force editbox to close?
Posted: Mon Feb 16, 2015 11:34 pm
by tulamide
I am going quite a similar route for the editor I want to do for your dsp/asm²
isKeyPressed does not work everywhere. It is bound to mouse actions. However, I could regularly open a new editbox each time the user enters the view with the mouse - without closing the previous one. And there were no issues. I did it with Ruby, if that makes a difference.
What would really be needed is a way to catch keystrokes before Flowstone interprets them, and flush them after use. Just like the MIDI key from pc keyboard input.
Re: Ruby: how to force editbox to close?
Posted: Tue Feb 17, 2015 8:08 pm
by KG_is_back
Here is, what I have so far... Scroll bars do not interact yet (you may scroll the text by dragging selections - view is adjusted so that cursor is always on screen) and also cursor does not react while editing text. Both of these are easy to add (I will do it in near future).
the editor has multiple parts, of which only the actual text editor is implemented.Top and bottom bars are empty yet, but will contain dropdown menus tabs and will show various data.
The code is drawn on screen char by char into a grid (because I was unable to determine line height and char width from font size or font itself, but that's another topic).
My first try was, to re-initiate edit box as empty, every time something is tiped in or pasted in. delete and backspace would be implemented separately if possible (as well as enter and tab which I've already done, because they cause edit box to close).
What is your approach Tulamide? Do you use edit box with transparent text and background and draw colored text underneath?
Re: Ruby: how to force editbox to close?
Posted: Wed Feb 18, 2015 2:56 am
by tulamide
KG_is_back wrote:What is your approach Tulamide? Do you use edit box with transparent text and background and draw colored text underneath?
Basically yes, just that I didn't make it transparent but offsetted it far outside the view (in fact even outside any possible screen size). I also did use it per key stroke. But you are far more advanced in that you already solved the text cursor positioning to a degree (that was my biggest issue). You would just need to take into account that backspace should delete also outside of the current edit box' text.
Tbh, I feel relieved that you are already so far, because I got the great opportunity to help with an awesome project. Since last week I spend all my time on that project, and so the editor didn't progress, which made me feel uneasy. Now that I know you're doing the same and already advanced, I can concentrate on the project unvexed

Re: Ruby: how to force editbox to close?
Posted: Wed Feb 18, 2015 3:07 am
by RJHollins
Hi KG,
Had a moment to load up your DSPCodeEditor example, and noticed a complaint from RUBY
Located in the 'full code edit' module, the inside RUBY block give a
"NoMethodError [in method event]: 'undefined method 'setViewSize'.
I should note that I'm running FS 3.0.4
I can reset that RUBY box, but the error returns when clicking on the main GUI. Again, this might be a version error.
Re: Ruby: how to force editbox to close?
Posted: Wed Feb 18, 2015 8:09 am
by KG_is_back
RJHollins wrote:Hi KG,
Had a moment to load up your DSPCodeEditor example, and noticed a complaint from RUBY
Located in the 'full code edit' module, the inside RUBY block give a
"NoMethodError [in method event]: 'undefined method 'setViewSize'.
I should note that I'm running FS 3.0.4
I can reset that RUBY box, but the error returns when clicking on the main GUI. Again, this might be a version error.
Yes, the method was added in 3.0.5. It can resize and reposition the view of a module.