Page 1 of 2
Is this a bug?
Posted: Tue Jul 08, 2008 4:34 am
by Patrick Mast
Hello,
Please try following with code below:
1. Start the app
2. In colomn 1, you see rows with 111,222 and 333
3. In the browse,
click with the mouse on row 2
4. Than,
click with the mouse on row 3 in the browse
5.
Now notice that column 1 of row 2 changed to 111
This is because I have the
oGet:SetFocus() in the bLine of the browse.
Let me explain what I want to do:
If the user selects a row with his mouse, I want the GET to display the value of Column1 in the selected row
AND set focus on the GET. This is important, because
it is the SETFOCUS() that makes the value change in the browse.
Is this a bug or do I need to do it in a different way?
Thanks!!
Patrick
Code: Select all
PROCEDURE Main()
LOCAL oDlg, oBrw, n:=1, oGet
LOCAL aData:={111,222,333}
DEFINE DIALOG oDlg FROM 0,0 TO 25, 80
@ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg
oBrw:bLine :={ || {Str(aData[n]),oGet:SetFocus()}}
oBrw:bGoTop :={ || n:=1 }
oBrw:bGoBottom:={ || n:=Len(aData) }
oBrw:bSkip :={ | nSkip, nOld | nOld := n, n += nSkip,;
n := Max( 1, Min( n, Len(aData) ) ),;
n - nOld }
oBrw:bLogicLen:={ || Len(aData) }
oBrw:cAlias :="Array"
@ 10,2 GET oGet VAR aData[n] OF oDlg SIZE 90, 10
ACTIVATE DIALOG oDlg
RETURN
Posted: Tue Jul 08, 2008 7:14 am
by nageswaragunupudi
>
Is this a bug or do I need to do it in a different way?
>
No bug in wbrowse.prg. We need to do it this way:
Code: Select all
#include 'fivewin.ch'
PROCEDURE Main()
LOCAL oDlg, oBrw, n:=1, oGet
LOCAL aData:={111,222,333}
DEFINE DIALOG oDlg FROM 0,0 TO 25, 80
@ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg
// oBrw:bLine :={ || {Str(aData[n]),oGet:SetFocus()}}
oBrw:bLine := { || {Str(aData[n]),' '} } // instead of the original line
oBrw:bGoTop :={ || n:=1 }
oBrw:bGoBottom:={ || n:=Len(aData) }
oBrw:bSkip :={ | nSkip, nOld | nOld := n, n += nSkip,;
n := Max( 1, Min( n, Len(aData) ) ),;
n - nOld }
oBrw:bLogicLen:={ || Len(aData) }
oBrw:cAlias :="Array"
oBrw:bChange := { || oGet:SetFocus() } // inserted
@ 10,2 GET oGet VAR aData[ n ] OF oDlg SIZE 90, 10
ACTIVATE DIALOG oDlg
RETURN
Posted: Tue Jul 08, 2008 7:32 am
by nageswaragunupudi
Because of my personal preference to xBrowse, I am tempted to post a working example with xBrowse also:
Code: Select all
#include 'fivewin.ch'
#include 'xbrowse.ch'
PROCEDURE Main()
LOCAL oDlg, oBrw, oGet
LOCAL aData:= { 111, 222, 333}
DEFINE DIALOG oDlg FROM 0,0 TO 25, 80
@ 0,0 XBROWSE oBrw ;
HEADERS 'Select' ;
SIZE 310,100 OF oDlg ;
ON CHANGE oGet:SetFocus() ;
ARRAY aData AUTOCOLS
oBrw:CreateFromCode()
@ 10,2 GET oGet VAR aData[ oBrw:nArrayAt ] OF oDlg SIZE 90, 10
ACTIVATE DIALOG oDlg CENTERED
RETURN
Posted: Tue Jul 08, 2008 3:15 pm
by mmercado
nageswaragunupudi wrote: oBrw:bChange := { || oGet:SetFocus() } // inserted
Hi both:
I think for Patrick's purposes it's better to use bLClicked instead of bChange because if user clicks the same row, the browse gain focus.
Regards.
Manuel Mercado
Posted: Tue Jul 08, 2008 4:02 pm
by Patrick Mast
nageswaragunupudi wrote:No bug in wbrowse.prg. We need to do it this way:
Code: Select all
#include 'fivewin.ch'
...
oBrw:bChange := { || oGet:SetFocus() } // inserted
Great! Thanks!
Now, this works OK if I click on one of the rows in the browse, but if I click on the browse itself, so NOT on a row with data in it, the GET does not get focused.
So to sumarize:
With oBrw:
bChange:={ || oGet:SetFocus() }
-> Click on row with data = OK
-> Click on oBrw =
NOT OK
-> Click on vertical scrollbar while row 2 is active -> OK
-> Move throug browse with keyboard arrows ->
NOT OK
With oBrw:
bLClicked:={ || oGet:SetFocus() }
-> Click on row with data = OK
-> Click on oBrw =
NOT OK
-> Click on vertical scrollbar while row 2 is active ->
NOT OK
-> Move throug browse with keyboard arrows ->
NOT OK
With oBrw:
bGotFocus:={ || oGet:SetFocus() }
-> Click on row with data =
NOT OK
-> Click on oBrw =
NOT OK
-> Click on vertical scrollbar while row 2 is active ->
NOT OK
-> Move throug browse with keyboard arrows ->
NOT OK
Patrick
Posted: Tue Jul 08, 2008 4:13 pm
by nageswaragunupudi
>
With oBrw:bChange:={ || oGet:SetFocus() }
-> Click on oBrw = NOT OK
>
How we program depends on what we want to happen for Cick on Brw in area not containing data
>
>
-> Move throug browse with keyboard arrows -> NOT OK
>
Moving through browse with key board arrows also changes the Get's value to the new row. I thought thats what is intended. If what is wanted is different, then we need to program for that
Posted: Tue Jul 08, 2008 4:40 pm
by Patrick Mast
nageswaragunupudi wrote:Moving through browse with key board arrows also changes the Get's value to the new row. I thought thats what is intended. If what is wanted is different, then we need to program for that
Yes, everything needs to work
Thanks for helping!
Antonio, do you have an idea?
Patrick
Posted: Thu Jul 10, 2008 5:58 am
by Patrick Mast
I have this bug in my application. Antonio, do you have a fix for this? Maybe anyone else with a fix for this?
Thanks!!
Patrick
Posted: Thu Jul 10, 2008 9:02 am
by Enrico Maria Giordano
Patrick, please explain what do you exactly want to do.
EMG
Posted: Thu Jul 10, 2008 3:10 pm
by Patrick Mast
Enrico Maria Giordano wrote:Patrick, please explain what do you exactly want to do.
Enrico,
Simple; I want the GET to ALWAYS have focus and it should have the value of the active row in the browse.
The problem started when I noticed that, when you use the scrollbar to navigate, the value IN the browse changed.
So, again, I want the GET to have ALWAYS focus and the value in the get should be the active row.
Thanks for helping!
Patrick
Posted: Thu Jul 10, 2008 4:06 pm
by nageswaragunupudi
If understand correctly, the intention is that the Browse should never get focus, whatever the user does, including Tabbing, clicking on non-data area of the browse or using the scroll bar.
The following code seems to work.
Code: Select all
PROCEDURE Main()
LOCAL oDlg, oBrw, n := 1, oGet
LOCAL aData:={111,222,333}
DEFINE DIALOG oDlg FROM 0,0 TO 25, 80
@ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg
oBrw:bLine := { || {Str(aData[n]),' '} }
oBrw:bGoTop :={ || n:=1 }
oBrw:bGoBottom :={ || n:=Len(aData) }
oBrw:bSkip :={ | nSkip, nOld | nOld := n, n += nSkip,;
n := Max( 1, Min( n, Len(aData) ) ),;
n - nOld }
oBrw:bLogicLen :={ || Len(aData) }
oBrw:cAlias :="Array"
oBrw:bChange := { || oGet:SetFocus() }
oBrw:bGotFocus := { || oGet:SetFocus() }
// following two lines to visibly make sure
// where the focus is
oBrw:nClrBackFocus := CLR_GREEN // browse shd never show green
SetGetColorFocus() // Get should always retain the color
@ 10,2 GET oGet VAR aData[n] OF oDlg SIZE 90, 10
ACTIVATE DIALOG oDlg CENTERED
RETURN
We may add oBrw:nStyle -= WS_TABSTOP. but this seems work even without that.
Does this example serve the intended purpose please?
Posted: Thu Jul 10, 2008 4:28 pm
by Patrick Mast
nageswaragunupudi wrote:If understand correctly, the intention is that the Browse should never get focus, whatever the user does, including Tabbing, clicking on non-data area of the browse or using the scroll bar.
The following code seems to work.
Code: Select all
PROCEDURE Main()
...
oBrw:bChange := { || oGet:SetFocus() }
oBrw:bGotFocus := { || oGet:SetFocus() }
...
RETURN
We may add oBrw:nStyle -= WS_TABSTOP. but this seems work even without that.
Does this example serve the intended purpose please?
Thank you but this behaves not correctly.
Please try this:
1. Start the app
2. Click on row 2
-> Get still has 111 as vallue, so this is wrong
3. Than click on row 3
-> The get still has vallue 111, but worse, the browse column 1 of row 2 ALSO gets the vallue of 111
4. Than click on row 2 again
-> The get still has 111, and the vallue of row 3 of the browse als has 111
Its the
changing of the vallues
IN the browse that got me thinking this is abug somewhere.
So, 2 things needs to be fixed here.
1. The vallue of the GET should get updated
2. The vallues in the browse schould NOT change
Thanks for helping!
Patrick
Posted: Thu Jul 10, 2008 4:58 pm
by Antonio Linares
IMO the GET should not directly modify aData[ n ], because when it loses focus (though later on, it recovers it) then aData[ n ] is asigned with the GET contents (111).
The GET should work on a local variable, and the bChange of the browse should update that local variable.
Unless I am missing something

Posted: Thu Jul 10, 2008 5:01 pm
by Antonio Linares
Code: Select all
#include "FiveWin.ch"
PROCEDURE Main()
LOCAL oDlg, oBrw, n := 1, oGet
LOCAL aData:={111,222,333}
LOCAL cValue := aData[ 1 ]
DEFINE DIALOG oDlg FROM 0,0 TO 25, 80
@ 0,0 LISTBOX oBrw FIELDS SIZE 310,100 OF oDlg
oBrw:bLine := { || {Str(aData[n]),' '} }
oBrw:bGoTop :={ || n:=1 }
oBrw:bGoBottom :={ || n:=Len(aData) }
oBrw:bSkip :={ | nSkip, nOld | nOld := n, n += nSkip,;
n := Max( 1, Min( n, Len(aData) ) ),;
n - nOld }
oBrw:bLogicLen :={ || Len(aData) }
oBrw:cAlias :="Array"
oBrw:bChange := { || oGet:VarPut( aData[ n ] ), oGet:Refresh(), oGet:SetFocus() }
oBrw:bGotFocus := { || oGet:SetFocus() }
// following two lines to visibly make sure
// where the focus is
oBrw:nClrBackFocus := CLR_GREEN // browse shd never show green
SetGetColorFocus() // Get should always retain the color
@ 10,2 GET oGet VAR cValue OF oDlg SIZE 90, 10
ACTIVATE DIALOG oDlg CENTERED
RETURN
Posted: Thu Jul 10, 2008 5:08 pm
by Patrick Mast
Antonio,
Works perfect!

Thank you very much.
Patrick