Android-java-code-utilities-widgets-for-Processing-for-Android icon indicating copy to clipboard operation
Android-java-code-utilities-widgets-for-Processing-for-Android copied to clipboard

Request: Multiline edit

Open uheinema opened this issue 5 years ago • 7 comments

As a Dialog or (better!) as a (transparent) overlay of your sketch display.

Great stuff!

Lots of tnx

Your brother in APDE.

uheinema avatar May 23 '20 13:05 uheinema

Ok, I thought I had posted something like that already. I´ll have to finish my current project first though. Since Google+ shut down on April 2nd, 2019, the then-existing forum ended. Wouldn't you like to open a new forum at Google forums like this one? Just for specific APDE related stuff? I didn't do it myself already because I don't know how much time I still have. BTW You can find me on P4A forum here.

EmmanuelPil avatar May 23 '20 17:05 EmmanuelPil

Thanks for pointing me there! Isn't the Processing forum the right place for this? Though I don't like the UI there very much. Keep it up!

uheinema avatar May 24 '20 16:05 uheinema

I've added the Edit Text box. You can combine other views like buttons, textViews etc. Just add them to the the layout, like "fl.addView(myButton);" The order in which you set them is important because they "float" above each other. All of them must have an unique id number to be called in the sketch within a runnable. If it is working for you, please comment on which android mode.

EmmanuelPil avatar Jun 05 '20 16:06 EmmanuelPil

Well, not too bad. Last line is buggy?? And superflous. Height way too small, increased:

Screenshot_20200605_235332_com calsignlabs apde sketchpreview Likes to be vertical centered, no scollbar... But a place to start, context menu works, input ok. Maybe it will become a reasonable "Notepad" with some effort.

So I thought, noting the View.OnKeyListener:

Ok, forget the display, maybe I can finally capture soft input this way - eg. Ä, when typed on screen.

But alas, the same as with all other methods i tried (overloading onkey..., dispatcher, what else...), different soft keyboards.. All with the same result: There simply is no event/call ... happening. All work with hardware (Blietooth) keyboards and on Ascii chars. No clue...and I'm not alone. From https://stackoverflow.com/questions/5419766/how-to-capture-soft-keyboard-input-in-a-view/7386854

Turns out that I did in fact need to subclass TextView and the use addTextChangedListener() to add my own implementation of TextWatcher in order to listen to soft key events. I couldn't find a way to do this with a plain old View.

uheinema avatar Jun 05 '20 22:06 uheinema

And so speaks Android Developers:

Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.

Of course afaik nowhere is explained HOW to catch software keypresses...

uheinema avatar Jun 06 '20 01:06 uheinema

So after some tinkering, this

https://github.com/uheinema/BoxDrop-Example/blob/master/Editfield/multiline.pde

is almost all I need.

  • Sorted out runUI/ nonUI stuff
  • alignment/gravity
  • textsize
edit.setTextSize(TypedValue.COMPLEX_UNIT_PX, ts);
  edit.setGravity(Gravity.START);

Just can't get scrollbars.

Tnx, Best regards

PS: If you like fancy buttons, I do them in a GLSL fragment shader...but that's another story.

uheinema avatar Jun 06 '20 02:06 uheinema

Hi again.

After some tinkering, it doesnt look too bad:

  • Size synced with Processing
  • Vertical scrollbar
  • proper alignment
  • Wrapped up for 'normal' Processing use(runonuithread madness).
  • and as a bonus: handling orientation changes etc.

See

https://github.com/uheinema/BoxDrop-Example/blob/master/README.md

uheinema avatar Jun 09 '20 20:06 uheinema