Commits (3)
  • Benoît Minisini's avatar
    ListEditor: Fix crash when checking for duplicates if the Unique property is TRUE. · 3a026766
    Benoît Minisini authored
    [GB.FORM]
    * BUG: ListEditor: Fix crash when checking for duplicates if the Unique property is TRUE.
    3a026766
  • Benoît Minisini's avatar
    Fix keyboard management, and windows cannot have focus anymore on click. · 7a1543f3
    Benoît Minisini authored
    [GB.GTK]
    * BUG: Fix keyboard event management for command keys like DEL that have a text associated with.
    * BUG: Windows cannot have focus anymore on click.
    
    [GB.GTK3]
    * BUG: Fix keyboard event management for command keys like DEL that have a text associated with.
    * BUG: Windows cannot have focus anymore on click.
    7a1543f3
  • Benoît Minisini's avatar
    Fix MaskBox. · 7ad6311a
    Benoît Minisini authored
    [GB.FORM]
    * BUG: MaskBox: Text that do not have the same size as the mask are not valid anymore.
    * BUG: MaskBox: The Text property now must match the mask when set. If the set text is smaller than the mask, it is completed with the default characters.
    * BUG: MaskBox: Characters moves should be handled better now.
    7ad6311a
# Gambas Project File 3.0
Title=More controls for graphical components
Startup=FTestValueBox
Startup=FTestMaskBox
Icon=.hidden/icon.png
Version=3.16.90
VersionFile=1
......@@ -10,7 +10,7 @@ Component=gb.form
Component=gb.settings
Component=gb.form.stock
Authors="Benoît Minisini"
Environment="GB_GUI=gb.qt5\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
Environment="GB_GUI=gb.gtk3\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en
......
......@@ -298,7 +298,7 @@ Private Sub CheckUnique()
I = 1
While I < lstData.Count
iPos = lstData.Find(lstData[I])
iPos = lstData.Find(lstData[I].Text)
If iPos <> I Then
lstData.Remove(I)
Else
......
......@@ -18,7 +18,7 @@ Property Read Editor As Control
'' Return or set if duplicates are allowed in the list.
''
'' By default, this property is 'FALSE' and duplicate are allowed.
'' By default, this property is 'FALSE' and duplicates are allowed.
Property Unique As Boolean
'' Return or set the index of the current item.
......
......@@ -81,21 +81,50 @@ End
Private Sub GetFirstCharacterPos() As Integer
Dim iPos As Integer
Dim sText As String
Dim sCar As String
For iPos = 0 To $aMask.Max
If $aMask[iPos] Then Return iPos
If $aMask[iPos] Then Break
Next
If IsRightAlign(iPos) Then
sText = UnmaskText(Super.Text)
While iPos < Me.Length
sCar = String.Mid$(sText, iPos + 1, 1)
If sCar <> UNMASKED_CHAR Then Break
Inc iPos
Wend
Endif
Return iPos
End
Private Sub GetLastCharacterPos() As Integer
Dim iPos As Integer
Dim sText As String
Dim sCar As String
For iPos = $aMask.Max DownTo 0
If $aMask[iPos] Then Return iPos + 1
If $aMask[iPos] Then
Inc iPos
Break
Endif
Next
If Not IsRightAlign(iPos) Then
sText = UnmaskText(Super.Text)
While iPos > 0
sCar = String.Mid$(sText, iPos + 1, 1)
If sCar <> UNMASKED_CHAR Then Break
Dec iPos
Wend
Endif
Return iPos
End
Private Sub UpdateMaskAndSeparator(sMask As String)
......@@ -290,10 +319,10 @@ Private Sub MaskText(sText As String) As String
Else If sMask = "[0-9]" Then
If sCar = $sPrompt And If bNumber Then
If sCar = UNMASKED_CHAR And If bNumber Then
sCar = "0"
Else If sCar = "0" And If Not bNumber Then
sCar = $sPrompt
sCar = UNMASKED_CHAR
Endif
If Not bNumber And If IsDigit(sCar) And If sCar <> "0" Then bNumber = True
......@@ -311,20 +340,13 @@ End
Private Sub GotoCursor(iPos As Integer) As Boolean
Dim sText As String = Super.Text
Dim sCar As String
If iPos < 0 Then iPos = GetFirstCharacterPos()
Dim iFirst As Integer
Dim iLast As Integer
If IsRightAlign(iPos) Then
While iPos < Me.Length
sCar = String.Mid$(sText, iPos + 1, 1)
If sCar <> $sPrompt And If sCar <> "0" Then
Break
Endif
Inc iPos
Wend
Endif
iFirst = GetFirstCharacterPos()
If iPos < iFirst Then iPos = iFirst
iLast = GetLastCharacterPos()
If iPos > iLast Then iPos = iLast
If Me.Pos <> iPos Then
Me.Pos = iPos
......@@ -333,11 +355,10 @@ Private Sub GotoCursor(iPos As Integer) As Boolean
End
Public Sub TextBox_KeyPress()
Dim sText, sTextOrg As String
Dim iOldPos, iPos, iPosPrev, iPosNext As Integer
Dim iPos, iPosPrev, iPosNext As Integer
Dim iMove As Integer
Dim sCar As String
Dim sInsert As String
......@@ -372,14 +393,14 @@ Public Sub TextBox_KeyPress()
iPos = GetLastCharacterPos()
Case Key.Delete
If iPos < Me.Length
If iPos < GetLastCharacterPos()
iMove = 0
bDelete = True
bBefore = IsRightAlign(iPos + 1)
Endif
Case Key.BackSpace
If iPos > 0 Then
If iPos > GetFirstCharacterPos() Then
iMove = -1
bDelete = True
bBefore = IsRightAlign(iPos)
......@@ -472,34 +493,41 @@ Public Sub TextBox_KeyPress()
Endif
Endif
iPos += iMove
If iMove Then
iOldPos = iPos
Do
iPos += iMove
If iPos < 0 Then
iPos = GetFirstCharacterPos()
Break
Endif
If iPos >= Me.Length Then
iPos = GetLastCharacterPos()
Break
Endif
If iMove > 0 Or If bDelete Then
If $aMask[iPos] Then Break
Endif
If iMove < 0 And If iPos > 0 And If $aMask[iPos - 1] Then Break
Loop
' iOldPos = iPos
' Do
' iPos += iMove
' If iPos < 0 Then
' iPos = GetFirstCharacterPos()
' Break
' Endif
' If iPos >= Me.Length Then
' iPos = GetLastCharacterPos()
' Break
' Endif
' If iMove > 0 Or If bDelete Then
' If $aMask[iPos] Then Break
' Endif
' If iMove < 0 And If iPos > 0 And If $aMask[iPos - 1] Then Break
' Loop
If IsRightAlign(iPos) Then
Do
If (iPos + iMove) < 0 Then Break
If (iPos + iMove) > Me.Length Then Break
sCar = String.Mid$(sText, iPos + 1, 1)
If sCar <> UNMASKED_CHAR And If sCar <> "0" Then Break
iPos += iMove
Loop
Endif
' If IsRightAlign(iPos) Then
' Do
' If (iPos + iMove) < 0 Then Break
' If (iPos + iMove) > Me.Length Then Break
' ' sCar = String.Mid$(sText, iPos + 1, 1)
' ' If iMove > 0 Then
' ' If sCar <> UNMASKED_CHAR Then Break
' ' Else
' ' If sCar <> "0" Then Break
' ' Endif
' iPos += iMove
' Break
' Loop
' Endif
Endif
......@@ -728,7 +756,7 @@ Private Sub IsValid(sText As String) As Boolean
If $sMaskOrg Then
If String.Len(sText) > $aMask.Count Then Return False
If String.Len(sText) <> $aMask.Count Then Return False
For I = 1 To String.Len(sText)
......@@ -811,6 +839,13 @@ End
Private Sub Text_Write(Value As String)
If $sMaskOrg Then
Value = Replace(Value, " ", $sPrompt)
If String.Len(Value) < $aMask.Count Then
Value &= String.Mid$(MakeDefault(), String.Len(Value) + 1)
Endif
Endif
Super.Text = Value
End
......
......@@ -6,3 +6,9 @@ Public Sub ListEditor1_Select()
Debug
End
Public Sub Form_Open()
ListEditor1.Index = 20
End
......@@ -4,6 +4,7 @@
MoveScaled(0,0,64,64)
{ ListEditor1 ListEditor
MoveScaled(5,6,48,34)
List = [("Élément 1"), ("Élément 2"), ("Élément 3"), ("Élément 4"), ("Élément 5")]
Unique = True
}
}
......@@ -7,34 +7,52 @@ Public Sub MaskBox1_Change()
End
Public Sub Button1_Click()
' Public Sub Button1_Click()
'
' ButtonBox1.Enabled = Not ButtonBox1.Enabled
'
' End
' Public Sub MaskBox1_Validate()
'
' Dim aAdr As String[]
' Dim I As Integer
' Dim sAdr As String
' Dim iAdr As Integer
' Dim bValid As Boolean
'
' aAdr = Split(Last.Text, ".")
' If aAdr.Count = 4 Then
' For I = 0 To aAdr.Max
' bValid = False
' sAdr = Trim(aAdr[I])
' If sAdr Then
' Try iAdr = CInt(sAdr)
' If Error Then Break
' If iAdr < 0 Or If iAdr > 255 Then Break
' Endif
' bValid = True
' Next
' Endif
'
' If Not bValid Then Stop Event
'
' End
Public Sub Form_Open()
MaskBox1.Text = " 30.35"
ButtonBox1.Enabled = Not ButtonBox1.Enabled
End
Public Sub TextBox1_KeyPress()
Debug Key.Code
End
Public Sub MaskBox1_Validate()
Dim aAdr As String[]
Dim I As Integer
Dim sAdr As String
Dim iAdr As Integer
Dim bValid As Boolean
aAdr = Split(Last.Text, ".")
If aAdr.Count = 4 Then
For I = 0 To aAdr.Max
bValid = False
sAdr = Trim(aAdr[I])
If sAdr Then
Try iAdr = CInt(sAdr)
If Error Then Break
If iAdr < 0 Or If iAdr > 255 Then Break
Endif
bValid = True
Next
Endif
If Not bValid Then Stop Event
Public Sub Form_GotFocus()
Debug
End
......@@ -2,13 +2,8 @@
{ Form Form
MoveScaled(0,0,64,64)
{ ButtonBox1 ButtonBox
MoveScaled(9,18,20,4)
Enabled = False
}
{ MaskBox1 MaskBox
MoveScaled(13,34,24,4)
Mask = "###<.###<.###<.###<"
Prompt = MaskBox.Bracket
Mask = "####0<!.0000"
}
}
......@@ -1290,6 +1290,8 @@ bool gControl::canFocusOnClick() const
{
/*if (_proxy)
return _proxy->canFocusOnClick();*/
if (isWindow())
return false;
if (!GTK_IS_BUTTON(widget))
return true;
return gt_get_focus_on_click(widget);
......
......@@ -238,7 +238,7 @@ bool gKey::mustIgnoreEvent(GdkEventKey *event)
if (!_im_has_input_method)
return false;
else
return (event->type == GDK_KEY_PRESS) && (event->keyval == 0 || !event->string || (uchar)*event->string >= 32);
return (event->type == GDK_KEY_PRESS) && (event->keyval == 0 || !event->string || ((uchar)*event->string >= 32 && ((event->keyval & 0xFF00) != 0xFF00)));
}
void gcb_im_commit(GtkIMContext *context, const char *str, gControl *control)
......
......@@ -902,7 +902,25 @@ void gMainWindow::setVisible(bool vl)
focus->setFocus();
focus = NULL;
}
else
{
gControl *ctrl = this;
for(;;)
{
ctrl = ctrl->nextFocus();
if (ctrl->isReallyVisible() && ctrl->isEnabled() && ctrl->canFocus())
{
ctrl->setFocus();
break;
}
if (ctrl == this)
break;
}
}
if (isSkipTaskBar())
_activate = true;
......