Looking for some MaxGUI TextArea help

Started by Adam Novagen, April 01, 2018, 19:27:14

Previous topic - Next topic

Adam Novagen

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.
We all know the main problem with dictionaries is that they contain too many words, and not enough butterscotch sauce!

Henri

#1
Hi,

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.

-Henri
- Got 01100011 problems, but the bit ain't 00000001