[Implemented] Cancel Button inside InputRequester

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] Cancel Button inside InputRequester

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

I always used my own InputRequester but now while changing
old code I realized:
"Hey, you could use the build-in InputRequester"

After changing the code I saw there is no 'Cancel' Button on it.

The user has to type something in to close the InputRequester.

THIS IS BAD!

Fred can you add a Cancel Button please :)

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> After changing the code I saw there is no 'Cancel' Button on it.
> The user has to type something in to close the InputRequester.

I wrote my own procedure for a superior input requester... see here:

viewtopic.php?t=2412

(Fred, no offense intended). :)


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Tomio.

Hello Franco,

perhaps you read my note "InputRequester always background" in the Bug Reports.

What is your experience with the requester window?

../tomio
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
By Tomio:
...the first call of "InputRequester" pops the window to forground.
But additional calls alway set it to background and I have to put away all windows arranged in front to enter text.
Well Tomio, I put the original InputRequester in the modified PureEdit file and I didn't had this experience.
Every time I called the input window, it was on top.
Maybe it's a OS thingy - I use WinXP (don't know what you used).

Anyway I have my own InputRequester and it works fine (should be on Paul's resourcesite with some other templates - since December 2001).
I also looked at Paul's (PB-Paul) ImputBox and it's not bad at all - but I don't like where the Buttons are located and that you have only one size of the InputBox.

So for now I use still my own.

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> I also looked at Paul's (PB-Paul) ImputBox and it's not bad at
> all - but I don't like where the Buttons are located and that you
> have only one size of the InputBox.

As mentioned, my InputBox procedure is an exact copy of Visual Basic's,
which is why the buttons are where they are. But what did you mean by
"only one size"? How do you resize PureBasic's InputRequester() then?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
Originally posted by PB

But what did you mean by
"only one size"? How do you resize PureBasic's InputRequester() then?
Sorry for being not concrete enough.
You can't change the size of PureBasic's InputRequester but mine does.

MyInputRequester(Title$,Message$,DefaultString$,SizeX)

SizeX = 3 ; Size = 422 for 64 visible characters
SizeX = 2 ; Size = 326 for 48 visible characters
SizeX = 1 ; Size = 230 for 32 visible characters
SizeX = 0 Or SizeX > 3 ; Size = 188 ; default size

SizeY = 135 ;Request Window height, always the same

I like to have it this way.

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> You can't change the size of PureBasic's InputRequester but mine does.

Ah, I see. :)

So what does your one look like? Care to post the procedure?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
Originally posted by PB

>
So what does your one look like? Care to post the procedure?
Ok, Ok...

Code: Select all

Procedure$ PG_InputRequester(PureGUI_Title$,PureGUI_Message$,PureGUI_DefaultString$,PureGUI_Size)
  PureGUI_SizeY = 135 ;always the same (old value=135)
  If PureGUI_Size = 3 : PureGUI_SizeX = 422 : EndIf ; for 64 characters
  If PureGUI_Size = 2 : PureGUI_SizeX = 326 : EndIf ; for 48 characters
  If PureGUI_Size = 1 : PureGUI_SizeX = 230 : EndIf ; for 32 characters
  If PureGUI_Size = 0 Or PureGUI_Size > 3 : PureGUI_SizeX = 188 : EndIf

  PureGUI_InputRequester = PG_Create(OpenWindow(PG_Count(#PG_Window),0,0,PureGUI_SizeX,PureGUI_SizeY,#PB_Window_ScreenCentered,PureGUI_Title$))

  PG_Create(TextGadget(PG_Count(#PG_Gadget), 12, 12, (PureGUI_SizeX - 30), 25, PureGUI_Message$))
  PureGUI_InputRequesterStringGadget = PG_Create(StringGadget(PG_Count(#PG_Gadget), 12, 42, (PureGUI_SizeX - 30), 22, PureGUI_DefaultString$))
  ActivateGadget(PureGUI_InputRequesterStringGadget)
  PureGUI_InputRequesterOK = PG_Create(ButtonGadget(PG_Count(#PG_Gadget), (PureGUI_SizeX - 175), 76, 76, 22, "OK"))
  PureGUI_InputRequesterCancel = PG_Create(ButtonGadget(PG_Count(#PG_Gadget), (PureGUI_SizeX - 94), 76, 76, 22, "Cancel"))

  SetForegroundWindow_(WindowID(PureGUI_InputRequester))
  Repeat
    PureGUI_EventID.l = WaitWindowEvent()
    If PureGUI_EventID = #PB_EventGadget
      Select EventGadgetID()
        Case PureGUI_InputRequesterOK 
          PureGUI_Result$=GetGadgetText(PureGUI_InputRequesterStringGadget)
          PureGUI_CloseInputRequester = 1
        Case PureGUI_InputRequesterCancel 
          PureGUI_Result$=""
          PureGUI_CloseInputRequester = 1
      EndSelect
    EndIf
  Until PureGUI_CloseInputRequester = 1
  CloseWindow(PureGUI_InputRequester) 
  ProcedureReturn PureGUI_Result$
EndProcedure
As you can see, my InputRequester is fully integreated in my PureGUI-Wrapper system.
This code will not work if you don't have the include file "PureGUI.pbi" for the automated window/gadget/etc numbering.

Anyway you can strip it down and take a look at it...

BTW: Yes you are right, the ESC key is not implemented etc. :)


Have a nice day...

Franco
Post Reply