Page 1 of 1

OpenDialog()

Posted: Sat Jul 04, 2020 2:17 pm
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 :-)

Re: OpenDialog()

Posted: Sat Jul 04, 2020 2:25 pm
by BarryG
Ty1003 wrote:Python. wx.Dialog.
I had a look at some images and they're just windows?

Re: OpenDialog()

Posted: Sat Jul 04, 2020 2:26 pm
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?

Re: OpenDialog()

Posted: Sat Jul 04, 2020 2:38 pm
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.

Re: OpenDialog()

Posted: Sat Jul 04, 2020 2:59 pm
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.

Re: OpenDialog()

Posted: Sat Jul 04, 2020 5:16 pm
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?

Re: OpenDialog()

Posted: Sat Jul 04, 2020 9:39 pm
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.

Re: OpenDialog()

Posted: Sat Jul 04, 2020 11:08 pm
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)

Re: OpenDialog()

Posted: Thu Jul 16, 2020 10:26 am
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.