Message: 'DefaultButton' is a new property that makes the first message dialog button the default one. It is TRUE by default to restore the last year behaviour.

[GB.GUI.BASE]
* NEW: Message: 'DefaultButton' is a new property that makes the first message dialog button the default one. It is TRUE by default to restore the last year behaviour.
This commit is contained in:
gambas 2022-01-12 17:09:45 +01:00
parent 4cd61da44e
commit d10dccaccd
4 changed files with 10 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# Gambas Project File 3.0
Title=Common controls and classes for GUI components
Startup=FMain
Startup=TestMessage
Icon=.hidden/window.png
Version=3.16.90
VersionFile=1
@ -8,7 +8,7 @@ Component=gb.image
Component=gb.gui
Component=gb.settings
Arguments=[["-style=oxygen"],["-style=qtcurve"]]
Environment="GB_REVERSE=1\nGB_JIT_DEBUG=1\nGB_GUI=gb.qt5\nLIBOVERLAY_SCROLLBAR=0\n GTK_DEBUG=interactive"
Environment="GB_JIT_DEBUG=1\nGB_GUI=gb.qt5\nLIBOVERLAY_SCROLLBAR=0\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en

View file

@ -101,7 +101,7 @@ Public Sub Display(sIcon As String, sText As String, aButton As String[], aDefau
'hButton.Foreground = Color.TextBackground
Endif
hButton.Cancel = True
hButton.SetFocus
If Not Message.DefaultButton Then hButton.SetFocus
Else If I = 0 Then
If Message.ColoredButtons And If aButton.Count >= 2 Then
If Application.DarkTheme Then
@ -111,6 +111,10 @@ Public Sub Display(sIcon As String, sText As String, aButton As String[], aDefau
Endif
'hButton.Foreground = Color.TextBackground
Endif
If Message.DefaultButton Then
hButton.Default = True
hButton.SetFocus
Endif
Endif
Next
hSpace = New Spring(panButton)

View file

@ -5,29 +5,10 @@ Export
Static Property Title As String Use $sTitle
Static Property Style As String
Static Property ColoredButtons As Boolean Use $bUseColor
Static Property DefaultButton As Boolean Use $bDefault = True
Static Private $sStyle As String
'Export
' GB_DESC CMessageDesc[] =
' {
' GB_DECLARE("Message", 0), GB_VIRTUAL_CLASS(),
'
' GB_STATIC_METHOD("_exit", NULL, CMESSAGE_exit, NULL),
'
' GB_STATIC_METHOD("_call", "i", CMESSAGE_info, "(Message)s[(Button)s]"),
' GB_STATIC_METHOD("Info", "i", CMESSAGE_info, "(Message)s[(Button)s]"),
' GB_STATIC_METHOD("Warning", "i", CMESSAGE_warning, "(Message)s[(Button1)s(Button2)s(Button3)s]"),
' GB_STATIC_METHOD("Question", "i", CMESSAGE_question, "(Message)s[(Button1)s(Button2)s(Button3)s]"),
' GB_STATIC_METHOD("Error", "i", CMESSAGE_error, "(Message)s[(Button1)s(Button2)s(Button3)s]"),
' GB_STATIC_METHOD("Delete", "i", CMESSAGE_delete, "(Message)s[(Button1)s(Button2)s(Button3)s]"),
'
' GB_STATIC_PROPERTY("Title", "s", CMESSAGE_title),
'
' GB_END_DECLARE
' };
'
Static Public Sub _call((Message) As String, Optional Button As String) As Integer
Return Info(Message, Button)

View file

@ -5,8 +5,8 @@ Use "gb.form.stock"
Public Sub Main()
' Print Message.Question("Ceci est un <i>message d'avertissement</i> dont le texte est <b>tout spécialement long</b> afin de tester la boite de dialogue. Toutes les modifications non enregistrées seront perdues !", "Sauvegarder", "Envoyer", "Annuler")
Message("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12")
Print Message.Question("Ceci est un <i>message d'avertissement</i> dont le texte est <b>tout spécialement long</b> afin de tester la boite de dialogue. Toutes les modifications non enregistrées seront perdues !", "Sauvegarder", "Envoyer", "Annuler")
'Message("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12")
Return
Dim p As String