PythonScript
PythonScript copied to clipboard
notepad.prompt() window and multiline input
I noticed that when I put some text in a notepad.prompt() window, e.g.:
notepad.prompt('', '', 'this is the default first line')
it correctly shows:

But then if I want to accept the first line and move input to a second line, using Ctrl+Enter, it erases my first line:

I have to remember to FIRST clear the selection (perhaps by pressing the End key) to obtain:

and then my Ctrl+Enter movement to the second line goes well:

But I always forget to do this unselect manually, so I was wondering if the plugin could handle this for me? Or maybe this is just how Windows' multiline edit boxes work, and the plugin can't handle it.
In that case, I'd ask for an option to not show the text in the box as selected when the prompt window first appears.
Using PS 2.0.
Something like a 4th parameter unselect, set to false by default, would be helpful.
a 4th parameter unselect, set to false by default, would be helpful.
Yes, I've often thought this.
Another use case is a poor-man's UI made out of the notepad.prompt() box, example (imitation checkboxes):
[ ]option1 [ x ]option2
Here, if the text is selected when the box appears, it is easy for the user to hit an unintended key -- maybe arrowing was intended to move to where a "checkbox" could be ticked, but... If that happens the "UI" is destroyed :-(
The relevant code for the text selection is at https://github.com/bruderstein/PythonScript/blob/d0b420e1201fb062eaf60c0d8bf58e80ffe92fd4/PythonScript/src/PromptDialog.cpp#L69
Removing that line will leave the caret at the beginning of the unselected text. See https://cplusplus.com/forum/windows/40365/ for the further necessary calls to avoid that.
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SETSEL, static_cast<WPARAM>(-1), -1);
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SCROLLCARET, 0, 0);
@alankilborn @Ekopalypse Do you see any advantage to keep the current behaviour with the selection of the text?
Do you see any advantage to keep the current behaviour with the selection of the text?
If it could be made an optional behavior, that would be nice. But I think in general it is unexpected behavior to be selected. And yes, caret should be at end of unselected text.
The only advantage I see right now is if someone uses it with a default value that needs to be overwritten from time to time.
I'd ask for an option to not show the text in the box as selected when the prompt window first appears.
Workaround:
import threading
import SendKeys as sk
threading.Timer(0.25, lambda : sk.SendKeys("{RIGHT}")).start() # remove highlight from prompted text
notepad.prompt('', '', 'Notice that I am not selected when the prompt box appears!')
Produces:
