I’m adding a button to my plugin that essentially hides all text in the text editors. When clicked, the strings inside the editors get about 10-15 newlines inserted, to push the content off the screen, then the scroll bar is disabled, so users can’t tell that text has been scrolled out of view, then the editor is set to “read only,” The only issue is now, that you can still scroll through the text by clicking and highlighting the newlines. I figured that removing the mouseListener to this component would do the trick:
but this is not keeping the editor from receiving mouse input, am I doing something incorrectly?
Adding a MouseListener duplicates the mouse event, therefore removing it doesn’t remove the original mouse events. However there is a flag you can set to indicate, that the component doesn’t want mouse clicks: Component:setInterceptsMouseClicks (false, false);
I don’t know if it has an effect on mouse wheel events as well, but worth a try.
BTW. I don’t understand what you want to achieve out of a users perspective. Wouldn’t editor.setVisible (false); be the more natural thing to do?
Thanks Daniel, I’ll try your suggestion.
As for your question, I don’t want to hide the editor. I’m trying to implement a mode called “stealth” that leaves the plugin looking exactly as if there was nothing typed into the editors at all, but still keep the information in them. Basically: textEditor->hideText(); / textEditor->showText(); - if they existed.
The idea is to be able to display the plugin to other people while keeping certain information hidden, notes the mixing engineer may have taken that they want out of the clients eye. Removing the editor looks fishy, as it leaves huge blank spots where the editor was. I want it to just look as if nothing was typed into them.
I could’ve simply removed the text and stored it in another string, but then I’d have to save another string to XML and deal with knowing when to push text from those background strings and when to simply hold on to them. I figured I’d just add new lines and disable the editor from being useable, but make it look visually the same as a blank editor.
You could give text and background the same color (don’t forget to change the highlighted color as well if you don’t disable text selection). This will hide the text from the unser without changing its contents.
You might also try and show bullets instead of letters (like in a password entry field)
Changing the color might be a cool thing to try. Never considered it. And I did consider using bullet points, as if it were a password, but I quickly realized that showing text hidden with bullet points wasn’t “stealthy” at all! Lol. It was even more obvious that it was a big secret. And there were issues with new lines. When set to password mode, newlines acted funny. I might try the color idea if I can’t keep the user from interacting with the editor - thanks.
Hey Daniel. Your suggestion with setting the mouse intercept worked flawlessly. Scrolling doesn’t work either, which is perfect since I already hide the scrollbars.
The trick with the colors is neat, but I would also consider keeping duplicate empty TextEditors to display in front of the “real” ones, in their exact positions, only when the stealth mode is activated.
With those, you don’t have to tamper at all with the original TextEditors.