October 20, 2021, 10:45:34

Author Topic: Looking for some MaxGUI TextArea help  (Read 1107 times)

Offline Adam Novagen

  • Jr. Member
  • **
  • Posts: 18
Looking for some MaxGUI TextArea help
« on: April 01, 2018, 19:27:14 »
MaxGUI and I have such a rough relationship. Not because it's bad, but simply because I understand about bugger all about it and it makes me feel embarrassingly novice again  :D

Alright so I'm bonking out a simple script editor for a separate project of mine. Current state is to get it properly parsing lines to format commands, strings and the like, auto-capitalizing commands where applicable; this of course all happens in a TextArea gadget. I've got a basic handle on using EVENT_GADGETACTION to track when something is typed or modified in the text area, at which point I run the parser.formatLine() method for the line that the cursor is currently located on, to set the syntax highlighting and auto-capitalization. So far so good.

The first hiccup came when I realized that if the user presses Enter/Return for a new line, the line that they were on wouldn't get formatted, because the editor is only looking at the line the cursor is currently on. So, I made a quick alteration that if the character directly behind the cursor was 10 or 13 for a line break, the parser would format the previous line instead. This works as a simple hack for hitting Enter, but what about other cases, such as if the user moves the cursor up or down with the arrow keys, or even worse, if they use the mouse to click on a completely different and arbitrary line?

Basically I'm looking for advice on how I can track any time the cursor actually changes position within the text area, whether via keyboard or mouse input, so that I can make sure the appropriate lines are being parsed each time.

Offline Henri

  • Sr. Member
  • ****
  • Posts: 355
Re: Looking for some MaxGUI TextArea help
« Reply #1 on: April 01, 2018, 19:38:28 »

perhaps you could use SetGadgetFilter to catch relevant key hits like enter and arrow-keys.
And for mouse there is EVENT_GADGETSELECT. Just keep track of previous line and compare if line has changed.

« Last Edit: April 01, 2018, 19:44:52 by Henri »
- Got 01100011 problems, but the bit ain't 00000001


SimplePortal 2.3.6 © 2008-2014, SimplePortal