Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DownArrow in Centered Checkbox in Grid
Message
From
05/04/2002 15:45:36
 
 
To
02/04/2002 16:00:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00577753
Message ID:
00641614
Views:
23
>>>>Hi All,
>>>>
>>>>From previous posts on the UT, I've created a container class so that I can have a checkbox centered in a grid colum. It all works well.
>>>>
>>>>I've noticed, though, when when a DownArrow is pressed when the checkbox has focus, the resulting action is like a Tab, i.e., focus moves to the the next column to the right in the grid, rather than moving down a row.
>>>>
>>>>I believe that this is due to the container, since when I put a regular checkbox in the column instead of the container, the DownArrow works as expected.
>>>>
>>>>Any input/help is appreciated.
>>>>
>>>>J
>>>>
>>>>P.S. The class is just a container with a checkbox, with the following code in the container init:
>>>>
>>>>
With this.ChkBox
>>>>  If Type("this.parent.ControlSource")#"U"
>>>>    .ControlSource = this.parent.ControlSource
>>>>  EndIf
>>>>  .Left = this.parent.Width/2 - .Width/2
>>>>  If this.Height > .Height
>>>>    .Top = this.parent.Height/2 - .Height/2
>>>>  EndIf
>>>>EndWith
>>>
>>>Jill,
>>>This works for me :
>>>
*CheckBox.Keypress
>>>Lparameters nKeyCode, nShiftAltCtrl
>>>With this.parent.parent.parent
>>>  lnRows = int((.Height - (sysmetric(8)+.HeaderHeight))/.RowHeight)
>>>  If nKeyCode = 24
>>>    Nodefault
>>>    If .RelativeRow = lnRows
>>>      .DoScroll(1)
>>>    Endif
>>>    .ActivateCell(.RelativeRow+1,.RelativeColumn)
>>>  Endif
>>>  If nKeyCode = 5
>>>    Nodefault
>>>    If .RelativeRow = 1
>>>      .DoScroll(0)
>>>    Endif
>>>    .ActivateCell(.RelativeRow-1,.RelativeColumn)
>>>  Endif
>>>Endwith
Cetin
>>
>>I was refered to this thread. I have a checkbox centered by wraping it with a container and I have the same key board action problem as mentioned here. I tried to add code in keypress as you suggested here. However, the keypress does not get fired at all. I added my centered checkbox through addobject method in column's init(). It works fine with mouse but not key board. Any idea what I did wrong? Thanks.
>
>Wein,
>This is what I currently use :
>
Define Class grdcheckbox As Container
>  Width = 14
>  Height = 17
>  BackStyle = 0
>  BorderWidth = 0
>  Name = "grdcheckbox"
>  Add Object check1 As Checkbox With ;
>  Top = 0, ;
>  Left = 0, ;
>  Width = 13, ;
>  BackStyle = 0, ;
>  Caption = "", ;
>  SpecialEffect = 1, ;
>  Name = "Check1"
>  Procedure Init
>  With This
>    .Resize()
>    .check1.ControlSource=.Parent.ControlSource
>  Endwith
>Endproc
>  Procedure Resize
>  With This.check1
>    .Left = (This.Parent.Width - .Width)/2
>  Endwith
>Endproc
>  Procedure check1.InteractiveChange
>  This.Parent.Parent.Parent.Refresh
>Endproc
>  Procedure check1.KeyPress
>  Lparameters nKeyCode, nShiftAltCtrl
>  Local lnRows
>  If nKeyCode=32
>    Replace (this.Controlsource) With !(this.Controlsource)
>    This.Refresh
>  Endif
>  If Inlist(nKeyCode,4,19,5,56,141,24,50,145,18,57,31,3,51,30)
>    Nodefault
>    With This.Parent.Parent.Parent
>      lnRows = (.Height-(.HeaderHeight+Iif( .ScrollBars % 2 = 1, Sysmetric(8),0)))/.RowHeight
>      Do Case
>      Case Inlist(nKeyCode,5,56,141) && Up
>        If !Bof(.RecordSource)
>          Skip -1 In (.RecordSource)
>        Endif
>        If Bof(.RecordSource)
>          Go Top In (.RecordSource)
>        Endif
>      Case Inlist(nKeyCode,24,50,145) && Down
>        If !Eof(.RecordSource)
>          Skip In (.RecordSource)
>        Endif
>        If Eof(.RecordSource)
>          Go Bottom In (.RecordSource)
>        Endif
>      Case Inlist(nKeyCode,18,57,31) && PageUp
>        If !Bof(.RecordSource)
>          Skip -1*lnRows In (.RecordSource)
>        Endif
>        If Bof(.RecordSource)
>          Go Top In (.RecordSource)
>        Endif
>      Case Inlist(nKeyCode,3,51,30) && PageDown
>        If !Eof(.RecordSource)
>          Skip lnRows In (.RecordSource)
>        Endif
>        If Eof(.RecordSource)
>          Go Bottom In (.RecordSource)
>        Endif
>      Case nKeyCode=4 && RightArrow
>        Keyboard("{TAB}")
>      Case nKeyCode=19 && LeftArrow
>        Keyboard("{BACKTAB}")
>      Endcase
>    Endwith
>  Endif
>Endproc
>Enddefine
>
Cetin

Thanks, Cetin.

I think the keypress problem I have encountered is due to the VFP container. It seems to me that I have to do something to manage the focus on the grid or the form. Since container in VFP does not handle the Focus Event, it passes the event to its container (not to its contained member).

When I move the arrow/tab key to the cell in the column, the focus event goes to column's current control, which in this case is a container. According to VFP, the focus event will be handled at the container's container. Therefore, the keypress code in checkbox will never be executed.

When I use mouse to click, the event is fired at checkbox and checkbox gets the focus. Therefore, it works fine.

Wei Lin
Previous
Reply
Map
View

Click here to load this message in the networking platform