Hello all,
This is my problem:
I have two lists
A and B
in A i have "Toto", "TITI", "TATA"
in b i have "TRAE", "TITI",tatan".
I want to manually drag and drop the texts common between list A and list B, in this case select "TITI" from the first list and drop it on the "TITI" of the second list and make sure that this word is associated with the word in the first list. Can someone guide me in the design of this module?
Thank you in advance
In fact what I want is to be able to point manually from the first list the common text between the two lists.
DRAG AND DROP
Re: DRAG AND DROP
If understood correctly:loulou2522 wrote:...manually drag and drop the texts common between list A and list B, in this case select "TITI" from the first list and drop it on the "TITI" of the second list and make sure that this word is associated with the word in the first list...
Code: Select all
Enumeration
#mainWindow
#list1
#list2
EndEnumeration
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#mainWindow, #PB_Ignore, #PB_Ignore, 600, 400,
"Drag & Drop Text Matching", wFlags)
TextGadget(#PB_Any, 20, 10, 200, 30, "List 1")
TextGadget(#PB_Any, 320, 10, 200, 30, "List 2")
ListViewGadget(#list1, 10, 40, 280, 350)
ListViewGadget(#list2, 310, 40, 280, 350)
EnableGadgetDrop(#list1, #PB_Drop_Text, #PB_Drag_Copy)
EnableGadgetDrop(#list2, #PB_Drop_Text, #PB_Drag_Copy)
AddGadgetItem(#list1, -1, "apples")
AddGadgetItem(#list1, -1, "oranges")
AddGadgetItem(#list1, -1, "grapes")
AddGadgetItem(#list1, -1, "bananas")
AddGadgetItem(#list1, -1, "peaches")
AddGadgetItem(#list1, -1, "mangoes")
AddGadgetItem(#list1, -1, "strawberries")
AddGadgetItem(#list2, -1, "bananas")
AddGadgetItem(#list2, -1, "strawberries")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #list1, #list2
Select EventType()
Case #PB_EventType_DragStart
sourceGadget = EventGadget()
selectedIndex = GetGadgetState(EventGadget())
selectedText$ = GetGadgetItemText(EventGadget(), selectedIndex)
DragText(selectedText$)
EndSelect
EndSelect
Case #PB_Event_GadgetDrop
dropGadget = EventGadget()
If dropGadget <> sourceGadget
For i = 0 To CountGadgetItems(dropGadget)
If GetGadgetItemText(dropGadget, i) = selectedText$
msg$ = selectedText$ + " exists in list " + Str(dropGadget)
MessageRequester("Drag & Drop", msg$)
matchFound = #True
Break
EndIf
Next i
If Not matchFound
AddGadgetItem(dropGadget, -1, EventDropText())
RemoveGadgetItem(sourceGadget, selectedIndex)
EndIf
matchFound = #False
EndIf
EndSelect
Until appQuit
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
-
- Enthusiast
- Posts: 504
- Joined: Tue Oct 14, 2014 12:09 pm
Re: DRAG AND DROP
In order to be clearer in my explanation, let's take an accounting example: I have recorded an accounting entry in my computer system and on receipt of the account statement by the bank I want to be able to point to this entry with the receipt from the bank.
Re: DRAG AND DROP
So, essentially, to drag an entry from your bank's electronic statement (viewed through an external application) over to a list in PureBasic, to find a match?loulou2522 wrote:...point to this entry with the receipt from the bank.
Code: Select all
Enumeration
#mainWindow
#list1
#list2
EndEnumeration
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#mainWindow, #PB_Ignore, #PB_Ignore, 600, 400,
"Drag & Drop Text Matching", wFlags)
TextGadget(#PB_Any, 20, 10, 200, 30, "Bank Statement")
TextGadget(#PB_Any, 320, 10, 200, 30, "Personal Records")
ListViewGadget(#list1, 10, 40, 280, 350)
ListViewGadget(#list2, 310, 40, 280, 350)
EnableGadgetDrop(#list1, #PB_Drop_Text, #PB_Drag_Copy)
EnableGadgetDrop(#list2, #PB_Drop_Text, #PB_Drag_Copy)
AddGadgetItem(#list1, -1, "31DEC20#789")
AddGadgetItem(#list1, -1, "19JAN21#456")
AddGadgetItem(#list1, -1, "28JAN21#123")
AddGadgetItem(#list2, -1, "31DEC20#789")
AddGadgetItem(#list2, -1, "02JAN21#123")
AddGadgetItem(#list2, -1, "15JAN21#666")
AddGadgetItem(#list2, -1, "19JAN21#456")
AddGadgetItem(#list2, -1, "22JAN21#789")
AddGadgetItem(#list2, -1, "28JAN21#123")
AddGadgetItem(#list2, -1, "30JAN21#999")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #list1, #list2
Select EventType()
Case #PB_EventType_DragStart
sourceGadget = EventGadget()
selectedIndex = GetGadgetState(EventGadget())
selectedText$ = GetGadgetItemText(EventGadget(), selectedIndex)
DragText(selectedText$)
EndSelect
EndSelect
Case #PB_Event_GadgetDrop
dropGadget = EventGadget()
If dropGadget <> sourceGadget
dropText$ = EventDropText()
For i = 0 To CountGadgetItems(dropGadget)
If GetGadgetItemText(dropGadget, i) = dropText$
SetActiveGadget(dropGadget)
SetGadgetState(dropGadget, i)
Break
EndIf
Next i
EndIf
sourceGadget = -1
EndSelect
Until appQuit
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
-
- Enthusiast
- Posts: 504
- Joined: Tue Oct 14, 2014 12:09 pm
Re: DRAG AND DROP
Thanks TI_99A
That's exactly what i want. For the treamtment i have to programm special treatment but know i have the strucutre of the programm
Have a nice day
That's exactly what i want. For the treamtment i have to programm special treatment but know i have the strucutre of the programm
Have a nice day
Re: DRAG AND DROP
Glad to hear it. The drag-&-drop works between the two list views, but it also accepts text drops from external applications.loulou2522 wrote:...That's exactly what i want.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel