Qbasicnews.com

Full Version: Drag and Drop Icon System
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is for a Gui system im making...
Im not using icons, but the same principle would apply

how would i have the program move the icon?

i have it set, so if its inside the movement area, and the LB is clicked, then it registers, but how would i allow it to move?

Alex~
I have guess.


Code:
Check if icon is clicked
Register it
start checking the ouse position
if it leaves the icon original space move the icon with it.
when released set thje icons coordinate.


I have no code though. Im not good at mice =P
WhiteTiger: Thanks

WEll, unfortunately, i already know that...i know that everything must be in comparison to the up left hand corner.....but i don't have any code...

RST, if u still have my hobbit 2d version kicking around, I think i had sum code in it like this (map editor)

Alex~
Does anyone have any code for this situation??????

Alex~
Hmmmmmm...here's just a guess

if bx = 1 then

xposition# = dx
yposition# = cx

You could set the mouse's coordinates in the icon's coordinates, so if the mouse's dx is at 30 and the mouse's cx is 15, the picture will appear there... I'm not entirely sure that would work tho...

(I might have those mixed up..)
i suppose it could work like this:

Code:
If MouseLB% then
cx% = Mousex% - Icon.x
cy% = Mousey% - Icon.y
Icon.x = Mousex% - cx%
Icon.y = Mousey% - cy%
End If

Alex~
Al man, look at the logic there. If cx% equals Mousex% subtract Icon.x, and Icon.x equals Mousex% subtract cx%, then

Icon.x = Mousex% - cx%
Icon.x = Mousex% - Mousex% - Icon.x
Icon.x = -Icon.x

:o

That doesn't look like it will work.
In the main loop:
Code:
...

IF MouseLB% AND cursorOnIcon(bla%) THEN
    movingIcon%=bla%
END IF

IF movingIcon%>0 THEN
    drawIcon mouseX%,mouseY%,movingIcon%
END IF

IF movingIcon%>0 AND NOT MouseLB%
    movingIcon%=0
END IF

...

Something like that?
Zap, i think that's exactly what im looking for...

Rick...y did u subtract the mousex twice?

Oz~
wait wtf!? Wasn't your screename just a day ago Alex at Ever Never?
Pages: 1 2