xBRowser drag & drop question

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello NageswaraRao,

there is still one problem. If I drop the record then the row where I drop is highlighted but the dragged row is one before. Maybe you have a solution for that too.
Best regards,
Otto
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello NageswaraRao,

If the xBrowser is starting on the first page than it inserts and highlights one line before where you drop.
If you are on the second or higher page it works perfectly.
Maybe you have some more ideas to solve this.
Thank you for your help.

Regards,
Otto
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

It has to be like that only. Suppose you dreg 5th item and drop on 10th item. Now 5th item will become 9th item. So the cursor has to move up to 9th row.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

NageswaraRao, thank you very much.
Best regards,
Otto
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

Otto,
can you create a small test of it and insert the sample on fwnips website?
Best Regards, Saludos

Falconi Silvio
alvaro533
Posts: 179
Joined: Sat Apr 19, 2008 10:28 pm
Location: Madrid, España

Post by alvaro533 »

Good evening,

How can you know if the user is dropping in the same windows it was dragged from? In my program you can open several mdichild windows. I don't want the user to drag to a different window.

Thank you very much.

Alvaro
alvaro533
Posts: 179
Joined: Sat Apr 19, 2008 10:28 pm
Location: Madrid, España

Post by alvaro533 »

I found it.

Passing the number oWnd:hWnd with uDropInfo information. Thank you,

Alvaro
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

With the recent xbrowse ( FWH 8.05 ) the following lines

Code: Select all

       oBrw:lButtonDown( nRow, nCol, nFlags )
       oBrw:lButtonUp(   nRow, nCol, nFlags )
can be replaced with

Code: Select all

       oBrw:SetPos( nRow, nCol, .t. )  // .t. for pixel
This is better and more reliable than the workaround I was using earlier.
Regards

G. N. Rao.
Hyderabad, India
alvaro533
Posts: 179
Joined: Sat Apr 19, 2008 10:28 pm
Location: Madrid, España

Post by alvaro533 »

Using
oBrw:SetPos( nRow, nCol, .t. )

does not set the browse in the position where you drop.

However it works with this 2 lines, am I missing something?

oBrw:lButtonDown( nRow, nCol, nFlags )
oBrw:lButtonUp( nRow, nCol, nFlags )

Thank you

Alvaro
Post Reply