Loading...
Logo
Processing Forum
Hi I'm following my learning curve with this library, but i've encountered one problem.

I have a grid of GTextFields, and I can manage jumping to the next one using TAB with GTabManager, but I can't manage the ENTER key.

EDIT: also forgot to mention that SHIFT+TAB doesn't work.


What I tried is:
Copy code
  1. void handleTextEvents(GEditableTextControl tc, GEvent event) {
      for (int row = 1; row < 21; row++) {
        for (int col = 1; col < 9; col++) {
          if ((tc == PrgFlds[row][col]) && (event == GEvent.ENTERED)) {
            if (PrgFlds[row][col].hasFocus()) {
                PrgFlds[row][col].setFocus(false);
            }
          }
        }
      }
    }
I've tried the same using GEvent.CHANGED and it works.
What am I missing?

By the way, I see the library creator  looks for feedbacks on the Gui Creator Tool. I've tried downloading that but it doesn't run. tried on LinuxMint13, latest library and latest Processing (2.0b6..beta, not alfa).

Thanks, Davide.

Replies(8)


I have a grid of GTextFields, and I can manage jumping to the next one using TAB with GTabManager, but I can't manage the ENTER key.
There is a bug in the code in that pressing the Enter key inside a GTextField does key does not fire an event. This will be corrected in the next version. In the GTextArea class the Enter key starts a new paragrapgh so does not fire an event and that will not be changed.

It would seem logical that pressing the Enter key in a GTextField object advances to the next GTextField if it has a tab manager, but would be innappropriate for a GTextArea. I will modify the next version of G4P so that pressing Enter in a GTextField advances if it has a tabmanager as well as firing a ENTERED event.

EDIT  I have made and tested these changes and they will be in the next release


EDIT: also forgot to mention that SHIFT+TAB doesn't work.
I just tried the example that comes with G4P and it worked for me (Windows 7  / Processing 2.0b6 / G4P 3.0.0). Unfortunately I don't have access to a Linux machine to test it.


By the way, I see the library creator  looks for feedbacks on the Gui Creator Tool. I've tried downloading that but it doesn't run. tried on LinuxMint13, latest library and latest Processing (2.0b6..beta, not alfa).
The GUI builder tool generates the code needed to create the G4P controls so is dependant on the version of G4P library. In creating G4P 3.0.0 I have spent the last 3-4 months rewriting the library from the ground up which means that the builder tool available at the moment is not compatible with the library and will not work with Processing V2??? because of changes in the IDE code.

I have been modifying the GUI builder tool to work with the new G4P library and Processing 2.0b6 and it is done, finished ready to distribute BUT then I discover that changes made in Processing 2.0b7 have broken the library.

So I have a choice either
1) Issue the new version of G4P and the GUI builder tool that work with 2.0b6
or
2) Modify the library so it works with 2.0b7

For me the second option is preferable but to do it correctly I need information about the new event management system and Event classes that are going to be used. I have posted a query and I am hopeful that it gets a responce soon.


Thanks for answering and I Really thank you for this Library.

I'm waiting for any new version and improvements. Sorry if I can't help other than try the library on linux.

about the tool, i just wanted to give it a try, but it is not so important. i prefer to draw "by hand"..

another thing that i think it could be added, is the possibility to GAlign the TextField to the right. in that way if I enter too many characters, and then erase them, i'll have the field always filled. (sorry for my english, i wish i could explain).

Davide.

about the tool, i just wanted to give it a try, but it is not so important. i prefer to draw "by hand".
Personally I always use the GUI builder tool (when available) and I created G4P!!!

The reasons I use the builder tool are
  • it is very fast to create or edit the GUI
  • I don't have to remember all that syntax
  • the GUI code is always has correct syntax
  • it leaves more time for the interesting algorithmic stuff.

another thing that i think it could be added, is the possibility to GAlign the TextField to the right. in that way if I enter too many characters, and then erase them, i'll have the field always filled. (sorry for my english, i wish i could explain).
I do not know of a single line text input control where the alignment is not left. If you expect the text length to be bigger that the field width then you could create the GTextField control with a horizontal scrollbar, which also ensures that the insertion point is always visible. When the field becomes full the text scrolls off the left.

BTW there is no need to apologise your English is very good.

A picture == 1000 words...
..to explain what i cannot fix, and in case to have some suggestion on how to do.

I need to fit in this window a series of lines, that's why i'd prefer the use of ENTER...just faster.
Then i still have to find the best way to save those datas in a file, and then to re-load then when i need.
If you see this pic you undestand why there's no space for scrollbars. Also i don't need them, because i should enter max 5 characters per TField.
The problem is that if I write 7 characters by mistake, and then erase the last 2, the string isn't re-aligned to the right.

Do you think ther is a better way of doing what I have in my mind? (I've done something similar last year with Python, but wanted to use Processing (it's faster!) this time...if possible!)

Davide.
This has been feature has been implemented and will be available in the next version of G4P to be released.
Use the text changed event to restrict the number of characters entered, you could also use this to perform other validation e.g. making sure numbers are being input.

Hi, another question on GTextFields:
Is it possible to have something like a GValueField, or the possibility to put numbers (as an int or a long) inside the GTextField?
That's why if someone wants to use the fields like i have to, by now one should convert a lot of strings to numbers back and forth to use those numbers.

Any idea?

Thanks, Davide.

Is it possible to have something like a GValueField.
Yes it is possible but it is not a priority at the moment as I have Processing compatability problems to be resolved first.

Perhaps you would raise it as an issue on GoogleCode