PureBasic Forum
https://www.purebasic.fr/english/

InputRequester pre-select flag
https://www.purebasic.fr/english/viewtopic.php?f=3&t=61391
Page 1 of 1

Author:  kenmo [ Fri Jan 09, 2015 2:34 am ]
Post subject:  InputRequester pre-select flag

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.

Author:  Little John [ Fri Jan 09, 2015 6:17 am ]
Post subject:  Re: InputRequester pre-select flag

+1

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

Author:  le_magn [ Sat Jan 10, 2015 7:15 pm ]
Post subject:  Re: InputRequester pre-select flag

+1

Author:  heartbone [ Thu Jan 29, 2015 8:07 am ]
Post subject:  Re: InputRequester pre-select flag

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 .

Author:  uwekel [ Thu Jan 29, 2015 8:32 am ]
Post subject:  Re: InputRequester pre-select flag

+1

Author:  PB Fanatic [ Thu Jan 29, 2015 8:46 am ]
Post subject:  Re: InputRequester pre-select flag

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.

Author:  heartbone [ Thu Jan 29, 2015 2:46 pm ]
Post subject:  Re: InputRequester pre-select flag

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:
InputRequester("SOFTWARE","message","string")
InputRequester("SOFTWARE","_______________________message_______________________","string")
InputRequester("SOFTWARE","                                               message                                            ","string")

Author:  PB Fanatic [ Thu Jan 29, 2015 3:02 pm ]
Post subject:  Re: InputRequester pre-select flag

Doesn't make it wider here. All 3 requesters in your code sample are the same width.

Author:  heartbone [ Thu Jan 29, 2015 3:05 pm ]
Post subject:  Re: InputRequester pre-select flag

It must be a Linux (only?) feature.
Sorry about that, but it is good to know about the compiler differences.

Author:  blueznl [ Thu Jul 11, 2019 10:49 pm ]
Post subject:  Re: InputRequester pre-select flag

Well, we didn't get it in the last four years :-) so is there a way around it? (WinAPI is ok.)

Author:  Mijikai [ Fri Jul 12, 2019 6:51 am ]
Post subject:  Re: InputRequester pre-select flag

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/windows/win32/controls/em-setsel

Author:  RSBasic [ Fri Jul 12, 2019 8:09 am ]
Post subject:  Re: InputRequester pre-select flag

Have fun:
Code:
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

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/