xBRowser drag & drop question
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
James
When the user drags KeyNo 12 over KeyNo 20, the dragged item has to sit between 19 and 20. So I am changing KeyNo 12 as 19.5.
Assume the user drags 10 over 20 again. Then KeyNo 10 is to be changed to a number between 19.5 and 20 ( 19.75 ). Another drag over 20 again? The new key number will be 19.875 and so on.
I chose more decimal places so that we dont hit a dead end soon.
In real time application, if we hit deadend our logic should renumber.
Hope I am clear
When the user drags KeyNo 12 over KeyNo 20, the dragged item has to sit between 19 and 20. So I am changing KeyNo 12 as 19.5.
Assume the user drags 10 over 20 again. Then KeyNo 10 is to be changed to a number between 19.5 and 20 ( 19.75 ). Another drag over 20 again? The new key number will be 19.875 and so on.
I chose more decimal places so that we dont hit a dead end soon.
In real time application, if we hit deadend our logic should renumber.
Hope I am clear
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
NageswaraRao,
>Hope I am clear
Yes, now I get it. I did this once by numbering the items in increments of 10--I never thought of using decimals. It's good that you mention renumbering since that will become an issue at some point. With a very small database perhaps you could renumber it for each drag & drop.
James
>Hope I am clear
Yes, now I get it. I did this once by numbering the items in increments of 10--I never thought of using decimals. It's good that you mention renumbering since that will become an issue at some point. With a very small database perhaps you could renumber it for each drag & drop.
James
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Thats how I made it earlier. Here is what you want now:
Code: Select all
STATIC FUNCTION DropOver( uDropInfo, nRow, nCol, nFlags, oBrw )
LOCAL nDragRec := uDropInfo
LOCAL nThisRec
LOCAL nThisKey
LOCAL nPrevKey := 0
LOCAL n
oBrw:lButtonDown( nRow, nCol, nFlags )
oBrw:lButtonUp( nRow, nCol, nFlags )
nThisRec := (oBrw:cAlias)->( RECNO() )
nThisKey := (oBrw:cAlias)->NUMMER
( oBrw:cAlias )->( dbSKIP( -1 ) )
IF !bof()
nPrevKey := ( oBrw:cAlias )->NUMMER
ENDIF
( oBrw:cAlias )->( dbGOTO( nDragRec ) )
( oBrw:cAlias )->NUMMER := ( nThisKey + nPrevKey ) / 2
// ( oBrw:cAlias )->( dbGOTO( nThisRec ) )
oBrw:Refresh()
if ( n := ( oBrw:cAlias )->( OrdKeyNo() ) ) < oBrw:nRowSel
oBrw:nRowSel := n
oBrw:Refresh()
endif
RETURN NIL
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
With the recent xbrowse ( FWH 8.05 ) the following lines
can be replaced with
This is better and more reliable than the workaround I was using earlier.
Code: Select all
oBrw:lButtonDown( nRow, nCol, nFlags )
oBrw:lButtonUp( nRow, nCol, nFlags )
Code: Select all
oBrw:SetPos( nRow, nCol, .t. ) // .t. for pixel
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India