OpenDialog()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Ty1003
User
User
Posts: 31
Joined: Thu May 14, 2020 10:31 pm

OpenDialog()

Post by Ty1003 »

This is something I've seen in a few programming languages and I think it would be really useful if also in PureBasic. It opens a Dialog (or the sort of Window you get when you do MessageRequester), but you can add your own controls to it. An example if you would like to see is in Python. wx.Dialog. I know PB already has a library called "Dialog" but you wouldn't have to make it it's own library, just add it to the "Gadget" section of the manual.
I hope you'll consider this :-)
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

Re: OpenDialog()

Post by BarryG »

Ty1003 wrote:Python. wx.Dialog.
I had a look at some images and they're just windows?
User avatar
Kiffi
Addict
Addict
Posts: 1362
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: OpenDialog()

Post by Kiffi »

@Ty1003:

If I look at the examples of wx.Dialog, then the Dialog-Libary is exactly what you are looking for.

Or did I get you wrong?
Hygge
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: OpenDialog()

Post by IdeasVacuum »

Hi Ty1003

A Dialog is a Window with a defined, specific commonplace purpose. So they are provided because most apps need them.

However, if none of the standard ones suit your needs, you simply make your own - at the end of the day, they are all Windows.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Ty1003
User
User
Posts: 31
Joined: Thu May 14, 2020 10:31 pm

Re: OpenDialog()

Post by Ty1003 »

Hi.
Yes, Dialogs are just Windows but they can contain text that's not in the window title but is read by ScreenReaders whenever alt tabbing back to it. EG, look at MessageRequester. Even with the #PB_MessageRequester_YesNo flag, the text is above both buttons, and I have not found a way to make custom Dialogs so that they behave like that.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: OpenDialog()

Post by Little John »

Ty1003 wrote:EG, look at MessageRequester. Even with the #PB_MessageRequester_YesNo flag, the text is above both buttons, and I have not found a way to make custom Dialogs so that they behave like that.
Your aim is to create a custom window that contains some text above some buttons?
Ty1003
User
User
Posts: 31
Joined: Thu May 14, 2020 10:31 pm

Re: OpenDialog()

Post by Ty1003 »

I'm not 100 percent sure that's how MessageRequester() looks, as I am blind, but I believe so.
Allow me to give an example that I, hope, people will be able to understand.
MessageRequester("Question", "Copy this to clipboard?", #PB_MessageRequester_YesNo)
My screen reader (NVDA) would read this like the following.
"Question Dialog Copy to clipboard? Yes button Alt+Y"
But if I tab over to the "No" button, and then leave the Window and come back to it, I would hear.
"Question Dialog Copy to clipboard? No button Alt+N"
And that is what I'm trying to create, but with my own buttons of course, as if I only wanted Yes and No I would use MessageRequester :D.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: OpenDialog()

Post by Little John »

The following code is an example of a custom dialog. Is this what you are after?

Code: Select all

; PB 5.72

EnableExplicit

; Windows
#WinMain = 0

; Gadgets
Enumeration
   #GadText
   #GadBtn1
   #GadBtn2
   #GadBtn3
EndEnumeration

Procedure ShowDialog (title$, message$)
   If OpenWindow(#WinMain, 20,20, 260,150, title$, #PB_Window_MinimizeGadget) = 0
      MessageRequester("Fatal error", "Can't create main window.", #PB_MessageRequester_Error)
      End
   EndIf
   
   TextGadget(#GadText, 50,30, 180,25, message$)
   
   ButtonGadget(#GadBtn1,  20,100, 50,25, "Sure")
   ButtonGadget(#GadBtn2,  90,100, 50,25, "Never")
   ButtonGadget(#GadBtn3, 160,100, 80,25, "What's that?")
EndProcedure


Define event.i, reply$

ShowDialog("Custom dialog", "Do you want a cup of coffee?")

Repeat
   event = WaitWindowEvent()
   
   Select event
      Case #PB_Event_Gadget
         Select EventGadget()
            Case #GadBtn1
               reply$ = "Good choice!"
            Case #GadBtn2
               reply$ = "Do you prefer tea?"
            Case #GadBtn3
               reply$ = "That's a black magic fluid."
         EndSelect
         MessageRequester("Reply from the program", reply$, #PB_MessageRequester_Info)
   EndSelect      
Until event = #PB_Event_CloseWindow

CloseWindow(#WinMain)
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: OpenDialog()

Post by Jac de Lad »

I know these dialogues from XProfan. They have slightly different behaviour (ESC=Alt+F4 etc.), but mostly they don't have an icon in the title bar. Maybe this info helps.
Post Reply