InputRequester pre-select flag

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

InputRequester pre-select flag

Post 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.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: InputRequester pre-select flag

Post by Little John »

+1

Also for StringGadget(), such a flag would be nice to have.
le_magn
Enthusiast
Enthusiast
Posts: 133
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia
Contact:

Re: InputRequester pre-select flag

Post by le_magn »

+1
Image
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: InputRequester pre-select flag

Post 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 .
Keep it BASIC.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: InputRequester pre-select flag

Post by uwekel »

+1
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
PB Fanatic
User
User
Posts: 49
Joined: Wed Dec 17, 2014 11:54 am

Re: InputRequester pre-select flag

Post 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.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: InputRequester pre-select flag

Post 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")
Keep it BASIC.
PB Fanatic
User
User
Posts: 49
Joined: Wed Dec 17, 2014 11:54 am

Re: InputRequester pre-select flag

Post by PB Fanatic »

Doesn't make it wider here. All 3 requesters in your code sample are the same width.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: InputRequester pre-select flag

Post by heartbone »

It must be a Linux (only?) feature.
Sorry about that, but it is good to know about the compiler differences.
Keep it BASIC.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: InputRequester pre-select flag

Post by blueznl »

Well, we didn't get it in the last four years :-) so is there a way around it? (WinAPI is ok.)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: InputRequester pre-select flag

Post 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
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: InputRequester pre-select flag

Post 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
Image
Image
Post Reply