forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Drag Item List 2 List Example

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Sep 11, 2002 5:34 am    Post subject: Drag Item List 2 List Example Reply with quote

Code:
REM    _____________________________________________________
REM   |\___________________________________________________/|
REM   | |                                                 | |
REM   | | SOURCE TITLE:    Drag Item List 2 List Example  | |
REM   | | ------------                                    | |
REM   | | SOURCE AUTHOR:   Garrett R. Hylltun             | |
REM   | | -------------                                   | |
REM   | | DATE:            10 September, 2002             | |
REM   | | ----                                            | |
REM   | | REQUIREMENTS:    VDS 4.x                        | |
REM   | | ------------                                    | |
REM   | | SOURCE STATUS:   Public Domain                  | |
REM   | | -------------                                   | |
REM   | | SOURCE DESCRIPTION:                             | |
REM   | | ------------------                              | |
REM   | |   This shows you how to drag an item from one   | |
REM   | | list to another list.  Drag back and fourth     | |
REM   | | between both lists.                             | |
REM   | |_________________________________________________| |
REM   |/___________________________________________________\|

  DIALOG CREATE,Drag Item List 2 List Example,-1,0,362,339
  DIALOG ADD,LIST,LIST1,0,0,160,316,,SORTED,CLICK
  DIALOG ADD,LIST,LIST2,0,202,160,316,,SORTED,CLICK
  DIALOG ADD,TEXT,TEXT1,70,178,10,166,N o    d r o p    z o n e
  DIALOG ADD,STATUS,STATUS1,
  REM   --- |-------------------------------------------------| ---
  REM   --- |   We need a couple of items in each list to     | ---
  REM   --- | play with for this example, so lets gosub to    | ---
  REM   --- | create some items.                              | ---
  REM   --- |-------------------------------------------------| ---
  Gosub LoadLists
  DIALOG SHOW
  Option Sleeptime,100
  Option Decimalsep,.
  REM   --- |-------------------------------------------------| ---
  REM   --- |   I like setting my variables at the start      | ---
  REM   --- | and null them.                                  | ---
  REM   --- |-------------------------------------------------| ---
  %%ListAction =
  %%ListSelect =
  %%ListIndex =
  %%ListItem =
  %%ListTo =
  %%Status =

:EventLoop
  Wait Event,0
  %E = @event()
  If %E
    Goto %E
  End
  Goto EventLoop

:Timer
  REM   --- |-------------------------------------------------| ---
  REM   --- |   Check to see if the mouse left button is down,| ---
  REM   --- | and if it is, we gather some info and check if  | ---
  REM   --- | it was clicked on one of our lists.             | ---
  REM   --- |-------------------------------------------------| ---
  If @mousedown(L)
    %%ListSelect = @focus()
    If @equal(%%ListSelect,LIST1)
      REM   --- |-------------------------------------------------| ---
      REM   --- |   List1 was selected, so we know that List2 is  | ---
      REM   --- | going to be the destination list.  Add list2 to | ---
      REM   --- | the %%ListTo variable for later use, grab index | ---
      REM   --- | of item and the item and put them in variables  | ---
      REM   --- | for later use.                                  | ---
      REM   --- |-------------------------------------------------| ---
      %%ListTo = LIST2
      %%ListItem = @item(%%ListSelect)
      %%ListIndex = @index(%%ListSelect)
    End
    If @equal(%%ListSelect,LIST2)
      REM   --- |-------------------------------------------------| ---
      REM   --- |   List2 was selected, so grab it's data, put    | ---
      REM   --- | List1 in the %%ListTo variable.                 | ---
      REM   --- |-------------------------------------------------| ---
      %%ListTo = LIST1
      %%ListItem = @item(%%ListSelect)
      %%ListIndex = @index(%%ListSelect)
    End
    If @not(@null(%%ListTo))
      REM   --- |-------------------------------------------------| ---
      REM   --- |   If either list was selected, %%ListTo will    | ---
      REM   --- | have something in it, otherwise, we don't even  | ---
      REM   --- | bother doing anything.                          | ---
      REM   --- |                                                 | ---
      REM   --- |   But if either were clicked, we now need to    | ---
      REM   --- | grab the mouse position and then repeat until   | ---
      REM   --- | the mouse button is let up.                     | ---
      REM   --- |-------------------------------------------------| ---
      parse "%V;%W",@mousepos()
      Repeat
        Wait "0.1"
        parse "%X;%Y",@mousepos()
        REM   --- |-------------------------------------------------| ---
        REM   --- |   We took mouse position above, now we keep     | ---
        REM   --- | checking to see if the mouse was moved.. If it  | ---
        REM   --- | was, then we change the icon and disable the    | ---
        REM   --- | list we are dragging from.  We also set a       | ---
        REM   --- | variable switch letting the rest of the code    | ---
        REM   --- | know we are now in drag mode.  We also change   | ---
        REM   --- | the cursor to a DRAG cursor to let the user     | ---
        REM   --- | know they are now in drag mode.                 | ---
        REM   --- |-------------------------------------------------| ---
        If @not(@equal(%X%Y,%V%W))
          If @null(%%Status)
            Dialog Disable,%%ListSelect
            Dialog Cursor,DRAG
            Dialog Set,Status1,Drag in progress....
            %%Status = DragNow
          End
        End
        REM   --- |-------------------------------------------------| ---
        REM   --- |   If in drag mode, we need to see where the     | ---
        REM   --- | mouse goes and what it is over.  If it's not    | ---
        REM   --- | over the list we want to drop on, then we need  | ---
        REM   --- | to change the cursor to a NODROP.  If it's over | ---
        REM   --- | the destination list, we change the cursor to   | ---
        REM   --- | a DRAG.                                         | ---
        REM   --- |-------------------------------------------------| ---
        If @equal(%%Status,DragNow)
          REM   --- |-------------------------------------------------| ---
          REM   --- |   Get the name of the element that the mouse    | ---
          REM   --- | is over with the @wintext(@winatpoint(%X,%Y))   | ---
          REM   --- |-------------------------------------------------| ---
          %%Element = @wintext(@winatpoint(%X,%Y))
          If @equal(%%Element,LIST1)
            Dialog Cursor,DRAG
          Elsif @equal(%%Element,LIST2)
            Dialog Cursor,DRAG
          Else
            Dialog Cursor,NODROP
          End
        End
      Until @not(@mousedown(l))
      If @equal(%%Status,DragNow)
        REM   --- |-------------------------------------------------| ---
        REM   --- |   Now the mouse button has been released, we    | ---
        REM   --- | need to see where it was released.  The         | ---
        REM   --- | destination list was put into %%ListTo, so we   | ---
        REM   --- | compare what element the mouse was over when it | ---
        REM   --- | was released to the destination in %%ListTo.    | ---
        REM   --- | If they are the same, then we can place the     | ---
        REM   --- | item into the other list and delete it from     | ---
        REM   --- | it's original list.  If not, then we do nothing | ---
        REM   --- | at all and we let the code continue to where    | ---
        REM   --- | it clears the variables and resets everything.  | ---
        REM   --- |-------------------------------------------------| ---
        If @equal(%%ListTo,%%Element)
          List Seek,%%ListSelect,%%ListIndex
          List Delete,%%ListSelect
          %%ListAction = Yes
          If @equal(%%ListSelect,List1)
            List Add,List2,%%ListItem
          Else
            List Add,List1,%%ListItem
          End
        End
      End
      Dialog Enable,%%ListSelect
      Dialog Cursor
      %%ListSelect =
      %%ListIndex =
      %%ListItem =
      %%ListTo =
      %%Status =
    End
  End
  Goto EventLoop

:Close
  Exit

:List1click
  If @equal(%%ListAction,Yes)
    Dialog Set,Status1,List1 was clicked and a drag action did occur
  Else
    Dialog Set,Status1,List1 was clicked but no drag occured
  End
  %%ListAction =
  Goto EventLoop

:List2click
  If @equal(%%ListAction,Yes)
    Dialog Set,Status1,List2 was clicked and a drag action did occur
  Else
    Dialog Set,Status1,List2 was clicked but no drag occured
  End
  %%ListAction =
  Goto EventLoop


:LoadLists
  REM   --- |-------------------------------------------------| ---
  REM   --- |   Here's our sub to fill the lists.. Nothing    | ---
  REM   --- | of major importance or interest here.           | ---
  REM   --- |-------------------------------------------------| ---
  List Add,List1,"BEEP"
  List Add,List1,"BINFILE"
  List Add,List1,"CLIPBOARD"
  List Add,List1,"DDE"
  List Add,List1,"DIALOG"
  List Add,List1,"DIRECTORY"
  List Add,List1,"ELSE"
  List Add,List1,"ELSIF"
  List Add,List1,"END"
  List Add,List1,"EXIT"
  List Add,List1,"EXITWIN"
  List Add,List1,"EXTERNAL"
  List Add,List2,"@ALT"
  List Add,List2,"@ASC"
  List Add,List2,"@ASK"
  List Add,List2,"@BINFILE"
  List Add,List2,"@BOTH"
  List Add,List2,"@CHR"
  List Add,List2,"@CLICK"
  List Add,List2,"@COLORDLG"
  List Add,List2,"@COUNT"
  List Add,List2,"@CR"
  List Add,List2,"@CTRL"
  List Add,List2,"@CURDIR"
  Exit


Last edited by Garrett on Thu Sep 12, 2002 12:05 am; edited 1 time in total
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Sep 11, 2002 6:13 am    Post subject: Reply with quote

Good example Smile
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Sep 11, 2002 9:04 pm    Post subject: Reply with quote

Yes, I agree with Sheep! Good job! Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Sep 11, 2002 9:05 pm    Post subject: Reply with quote

By the way...if you don't want the spaces to be messed up, use the CODE tag. I changed over from VDS tag to CODE when I need correct spacing...
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Thu Sep 12, 2002 12:00 am    Post subject: Reply with quote

Ok... that sounds good too then. Thanks for the note on that. I
use to use just the code tag, but thought the vds tag was kind of
cool, but not if it's going to mess with spaces.

-Garrett
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Sep 12, 2002 9:39 pm    Post subject: Reply with quote

Yes, the VDS tag is cool, but it should keep the spaces aligned and maybe it could use the courier font that the VDS IDE uses by default...
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group