Drag/Drop Text Not working

Just starting out? Need help? Post your questions and find answers here.
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Re: Drag/Drop Text Not working

Post by Jumbuck »

Hey Guys,
I only want some code to drag the text in a TextGadget to a StringGadget on the same window
using Windows7 Professional 32Bit. If it will only be of use in my own program then so be it.
If there is a another method to avoid using Drag Drop then I would appreciate the code.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4792
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Drag/Drop Text Not working

Post by Fangbeast »

If I understand correctly, then I agree. Is this discussion saying that drag/drop
no longer exists on Windows 8?
No, drag and drop does work on Windows 8, between Windows 8 applications but there are many instances (too many to count) where dragging and dropping from third party applications to windows applications doesn't work properly, consistently or at all.

From all the forums that I have visited and read up on the phenomena, it has all to do with security layers in Windows that appear to be seeing dropped items as a security risk.

The solutions in these forums nearly always involve *hacking* windows itself to remove the security layer responsible for the problem, not something to be taken lightly and not something you could tell your customers to do!!!

Now, while I understand that this is a potential security risk and the changes made reflect a better layer of security unthought of in previous versions of Windows (Indeed, I would never, ever have thought of drag and drop as a security risk but now I understand why and I think everyone will 'get' it), I do not understand why a simple system of addable permissions could not have simply solved this problem.

Most of us have used manifest files at some time to add in the ability to gain elevated rights at runtime in our applications or set our programs to run as administrator at startup and this logically (to me) would signify that our program is now trusted enough (?) to be not a security (because we said so by making the software administrator) risk and thus drag and drop should not be a problem. But it is and this trick doesn't work either.

There should be some simple way we can add our programs to a trusted list on a windows 8 computer so this simple fucntion should not be the utter shemozzle that it is (Great word, been wanting to use it for years) after all, we can do this with AntiVirus programs, AntiSpy programs, AntiMalware programs etc, etc. MS is just a bit slow:):)

Okay, okay, it's been a slow day and I don't get to elocute very often:):)

Blame srod for not sending me a fresh sheep.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Re: Drag/Drop Text Not working

Post by Jumbuck »

Hey Guys
As my old code is not working all I was hoping for is updated code for PB5.11 to Drag the Text
in a TextGadget and Drop the text into a StringGadget on the same window.
If it means only workable in my own project then so be it.
If there is another method to achieve this can somebody post me the code.
Thanks
User avatar
TI-994A
Addict
Addict
Posts: 2741
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Drag/Drop Text Not working

Post by TI-994A »

Jumbuck wrote:...I was hoping for is updated code for PB5.11 to Drag the Text in a TextGadget and Drop the text into a StringGadget on the same window...
Hi Jumbuck. With PureBasic's built-in drag & drop functions, I don't believe that the TextGadget() or StringGadget() support dragging. However, the StringGadget() does seem to accept drops:

Code: Select all

Enumeration 
  #Window
  #List1
  #List2
  #String
  #Label1
  #Label2
EndEnumeration

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#Window, 0, 0, 550, 200, "Drag & Drop", wFlags)
StringGadget(#String, 360, 160, 180, 30, "")
ListIconGadget(#List1, 10, 10, 180, 180, "List 1", 170)   
ListIconGadget(#List2,  360, 10, 180, 140, "List 2", 170)
TextGadget(#Label1, 200, 60, 150, 20," <--- drag both ways --->", #PB_Text_Center)
TextGadget(#Label2, 200, 165, 150, 20," |--- drag one way only --->", #PB_Text_Center)
AddGadgetItem(#List1, -1, "Hello World!")
AddGadgetItem(#List1, -1, "Hello PureBasic!")
AddGadgetItem(#List1, -1, "Hello Jumbuck!")
EnableGadgetDrop(#String, #PB_Drop_Text, #PB_Drag_Copy)
EnableGadgetDrop(#List1, #PB_Drop_Text, #PB_Drag_Copy)
EnableGadgetDrop(#List2, #PB_Drop_Text, #PB_Drag_Copy)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      appQuit = 1
    Case #PB_Event_Gadget 
      If EventType() = #PB_EventType_DragStart
        Select EventGadget()
          Case #List1, #List2
            Text$ = GetGadgetItemText(EventGadget(), GetGadgetState(EventGadget()))
            DragText(Text$)
        EndSelect
      EndIf
    Case #PB_Event_GadgetDrop
      Select EventGadget()
        Case #List1, #List2
          AddGadgetItem(EventGadget(), -1, EventDropText())
        Case #String
          SetGadgetText(#String, EventDropText())
      EndSelect
  EndSelect
Until appQuit
Not really much, but hope it helps in some way. :D
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 :D
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Re: Drag/Drop Text Not working

Post by Jumbuck »

TI-994A
Thanks. All the examples I could find never referred to Drag/Drop for a TextGadget or StringGadget
only ListIcons, Files, or TreeGadgets or Images.
I don't know why never tried to Drag from a StringGadget to another StringGadget but using
my old code posted it works fine on the same window. Maybe all the forum reference to Windows
blocking only applies under certain conditions. Maybe it will crash under Windows 8 but I don't
have a copy to test with. Maybe some member will using my code example.
Post Reply