From f00f1c6c43bda4bb283ac0dd2aa03e22772a4cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 8 Oct 2010 21:51:28 +0000 Subject: [PATCH] [GB.FORM] * NEW: ListContainer now handles keyboard navigation and activation of its items. git-svn-id: svn://localhost/gambas/trunk@3263 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- app/src/gambas3/.src/CCoolButton.class | 5 ++- comp/src/gb.form/.info | 4 ++ comp/src/gb.form/.project | 2 +- comp/src/gb.form/.src/FMain.form | 8 ++-- comp/src/gb.form/.src/ListContainer.class | 55 ++++++++++++++++++++++- 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/app/src/gambas3/.src/CCoolButton.class b/app/src/gambas3/.src/CCoolButton.class index 8fd27c070..4caf1a611 100644 --- a/app/src/gambas3/.src/CCoolButton.class +++ b/app/src/gambas3/.src/CCoolButton.class @@ -10,6 +10,7 @@ Private $hPanel As DrawingArea Private $hImage As PictureBox Private $hLabel As TextLabel Private $iColor As Integer +Private $bInside As Boolean Event Click() @@ -52,7 +53,7 @@ End Private Sub UpdateBorder() - $hPanel.Border = If($hPanel.Hovered Or $hPanel.HasFocus, Border.Plain, Border.None) + $hPanel.Border = If($bInside Or $hPanel.HasFocus, Border.Plain, Border.None) End @@ -67,6 +68,7 @@ Public Sub Panel_Enter() $iColor = hPanel.Foreground hPanel.Background = Color.LightBackground '&88D5FF& hPanel.Foreground = Color.Foreground '&88D5FF& + $bInside = True UpdateBorder End @@ -80,6 +82,7 @@ Public Sub Panel_Leave() hPanel.Background = Color.Default 'Last.Parent.Background hPanel.Foreground = $iColor + $bInside = False UpdateBorder End diff --git a/comp/src/gb.form/.info b/comp/src/gb.form/.info index 2778042ef..8d8e7cccc 100644 --- a/comp/src/gb.form/.info +++ b/comp/src/gb.form/.info @@ -1048,6 +1048,10 @@ Unlock m +ScrollView_KeyPress +m + + #MenuButton UserControl C diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index eac02bf1b..e10f0c377 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -9,7 +9,7 @@ Component=gb.gui Component=gb.form Component=gb.settings Authors="Benoît Minisini" -Environment="GB_GUI=gb.gtk" +Environment="GB_GUI=gb.qt4" TabSize=2 Translate=1 Language=en diff --git a/comp/src/gb.form/.src/FMain.form b/comp/src/gb.form/.src/FMain.form index 0f51e80e8..c2ee268a4 100644 --- a/comp/src/gb.form/.src/FMain.form +++ b/comp/src/gb.form/.src/FMain.form @@ -1,14 +1,14 @@ # Gambas Form File 3.0 { Form Form - MoveScaled(0,0,97,52) + MoveScaled(0,0,97,56) { tv TableView MoveScaled(3,1,34,30) Expand = True Header = GridView.Both } { Panel1 Panel - MoveScaled(1,34,90,8) + MoveScaled(1,47,90,8) { ComboBox1 ComboBox MoveScaled(2,2,24,4) List = [("Élément 1"), ("Élément 2"), ("Élément 3"), ("Élément 4"), ("Élément 5")] @@ -25,7 +25,7 @@ MoveScaled(53,2,8,4) } } - { SidePanel1 SidePanel - MoveScaled(42,5,36,24) + { FontChooser1 FontChooser + MoveScaled(39,2,54,43) } } diff --git a/comp/src/gb.form/.src/ListContainer.class b/comp/src/gb.form/.src/ListContainer.class index c695bc4fb..1db33843c 100644 --- a/comp/src/gb.form/.src/ListContainer.class +++ b/comp/src/gb.form/.src/ListContainer.class @@ -288,7 +288,7 @@ Public Sub EnsureVisible() End -Public Sub Select(hChild As control) +Public Sub Select(hChild As Control) SetSelected(hChild) EnsureVisible @@ -339,3 +339,56 @@ Public Sub Unlock() If $iLock = 0 Then Me.Arrangement = Arrange.Vertical End + +Public Sub ScrollView_KeyPress() + + Dim hCurrent As Control + Dim iIndex As Integer + + If Not Key.Normal Then Return + + iIndex = Index_Read() + + If Key.Code = Key.Up Then + While iIndex > 0 + Dec iIndex + Index_Write(iIndex) + If Index_Read() = iIndex Then + Stop Event + Return + Endif + Wend + Else If Key.Code = Key.Down Then + While iIndex < (Count_Read() - 1) + Inc iIndex + Index_Write(iIndex) + If Index_Read() = iIndex Then + Stop Event + Return + Endif + Wend + Else If Key.Code = Key.Home Then + iIndex = 0 + While iIndex < Count_Read() + Index_Write(iIndex) + If Index_Read() = iIndex Then + Stop Event + Return + Endif + Inc iIndex + Wend + Else If Key.Code = Key.End Then + iIndex = Count_Read() - 1 + While iIndex > 0 + Index_Write(iIndex) + If Index_Read() = iIndex Then + Stop Event + Return + Endif + Dec iIndex + Wend + Else If Key.Code = Key.Space Then + If GetSelected() Then Raise Activate + Endif + +End