Page 1 of 1

InputRequester pre-select flag

Posted: Fri Jan 09, 2015 2:34 am
by kenmo
Here is a simple low-priority request:
A new flag for InputRequester (maybe #PB_InputRequester_Select) which will automatically pre-select all the text in the input field.

(We already have a Flags parameter for #PB_InputRequester_Password!)


It is handy for quick InputRequesters with DefaultText, so the user can immediately start typing to replace it. No need to keep hitting Ctrl+A or using the mouse to select every time.

In my experience, it is more common to type over the DefaultText completely, rather than append to the end -- where the cursor currently defaults.

Re: InputRequester pre-select flag

Posted: Fri Jan 09, 2015 6:17 am
by Little John
+1

Also for StringGadget(), such a flag would be nice to have.

Re: InputRequester pre-select flag

Posted: Sat Jan 10, 2015 7:15 pm
by le_magn
+1

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 8:07 am
by heartbone
Up until today, I thought that the behavior of the Input Requester in Linux which preselects the default was best.
However a couple of hours ago I implemented a chat program where the user initiates text entry by pressing a key.
That key is captured and passed into the Input Requester as the first character of the user's input.
On Windows® that approach works well, because the text is not preselected, and the user continues to type the chat message naturally without interruption then hits the enter key to send it on its way.
With the preselected requester input on Linux, the second keystroke wipes out the first one which is not nice.
Indeed kenmo, a pre-selection option setting would be a good solution .

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 8:32 am
by uwekel
+1

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 8:46 am
by PB Fanatic
Good request. :)

I would like to also request that the InputRequester window be larger, too. It's positively small for any meaningful entry, especially on big monitors.

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 2:46 pm
by heartbone
PB Fanatic wrote:I would like to also request that the InputRequester window be larger, too. It's positively small for any meaningful entry, especially on big monitors.
I discovered one way to make it wider.

Code: Select all

InputRequester("SOFTWARE","message","string")
InputRequester("SOFTWARE","_______________________message_______________________","string")
InputRequester("SOFTWARE","		                                   		message		                                		","string")

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 3:02 pm
by PB Fanatic
Doesn't make it wider here. All 3 requesters in your code sample are the same width.

Re: InputRequester pre-select flag

Posted: Thu Jan 29, 2015 3:05 pm
by heartbone
It must be a Linux (only?) feature.
Sorry about that, but it is good to know about the compiler differences.

Re: InputRequester pre-select flag

Posted: Thu Jul 11, 2019 10:49 pm
by blueznl
Well, we didn't get it in the last four years :-) so is there a way around it? (WinAPI is ok.)

Re: InputRequester pre-select flag

Posted: Fri Jul 12, 2019 6:51 am
by Mijikai
blueznl wrote:Well, we didn't get it in the last four years :-) so is there a way around it? (WinAPI is ok.)
Maybe u can send a #EM_SETSEL message to do that.
https://docs.microsoft.com/en-us/window ... /em-setsel

Re: InputRequester pre-select flag

Posted: Fri Jul 12, 2019 8:09 am
by RSBasic
Have fun:

Code: Select all

EnableExplicit

Define EventID
Define Text$

Procedure RequesterCallBack(hWnd, uMsg, wParam, lParam)
  hWnd = FindWindow_("InputRequester",#Null)
  If hWnd
    hWnd = FindWindowEx_(hWnd,#Null,"Edit",#Null)
    If hWnd
      SendMessage_(hWnd,#EM_SETSEL,5,10)
    EndIf
  EndIf

  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0,0,0,500,400,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ButtonGadget(1,10,10,100,20,"InputReq.",0)
 
  SetWindowCallback(@RequesterCallBack())
 
  Repeat
    EventID=WaitWindowEvent()
    If EventID=#PB_Event_Gadget
      Select EventGadget()
        Case 1
          Text$ = InputRequester("Enter text", "Enter a text:", "Predefined text")
          If Text$
            Debug Text$
          EndIf
      EndSelect
    EndIf
    If EventID = #PB_Event_CloseWindow
      End
    EndIf
  ForEver
EndIf