News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Pages (2): « First [1] 2 Next > Last »
drag 'n drop from external applications?
Author Message
znarf
Junior Member
**


Posts: 34
Group: Registered
Joined: Jun 2007
Status: Offline
Reputation: 0
Post: #1
MyBB  drag 'n drop from external applications?

Hi,
I'm currently evaluating the suitability of murgaLua for my needs and tried to build a basic application that receives drag and drop events from other applications (e.g., dragging file names from an explorer window on the murgaLua FLTK window).
In normal FLTK I'd to derive my own window class from Fl_Window and overwrite the handle() method in order to be able to reiceive and respond correctly to DND events, however, I'm not sure how to translate this to murgaLua. I've found the demo event_detection.lua, but this does not tell me how to correctly respond to such events.
Is there a way to implement a custom handle() method/callback, or is the handling of arbitrary events currently beyond murgaLua's scope?

Thanks for any reply, this is a great project!

06-25-2007 06:08 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #2
RE: drag 'n drop from external applications?

znarf Wrote:
Hi,
I'm currently evaluating the suitability of murgaLua for my needs and tried to build a basic application that receives drag and drop events from other applications (e.g., dragging file names from an explorer window on the murgaLua FLTK window).
In normal FLTK I'd to derive my own window class from Fl_Window and overwrite the handle() method in order to be able to reiceive and respond correctly to DND events, however, I'm not sure how to translate this to murgaLua. I've found the demo event_detection.lua, but this does not tell me how to correctly respond to such events.
Is there a way to implement a custom handle() method/callback, or is the handling of arbitrary events currently beyond murgaLua's scope?

Thanks for any reply, this is a great project!

I've been playing with this as well and have not figured out how to drop something on a FLTK widow or widget.

07-16-2008 12:38 PM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #3
RE: drag 'n drop from external applications?

I had once had a very inconsistent drag-and-drop working after several hours of hair pulling, but it seemed to work only if you dragged and dropped very deliberately, and only in certain desktop environments (definitely not portable). At the time I thought it was too flakey to bother with any further, so haven't touched it since, but you might be able to make something of it.

Code:
function dnd_check()
  if Fl:event() == fltk.FL_DND_RELEASE then
    Fl:paste(window)
    Fl:wait()
    local dropped_file=Fl:event_text()
    if dropped_file then
      print(dropped_file)
    end
  end
Fl:wait()
  timer:doWait(0.05)
end

timer=murgaLua.createFltkTimer()
timer:callback(dnd_check)
timer:do_callback()

07-17-2008 01:16 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #4
RE: drag 'n drop from external applications?

Hey thanks! I'll give it a shot.
Dan

07-17-2008 05:50 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #5
RE: drag 'n drop from external applications?

Keep in mind that I haven't looked at the result of this code in many months, so I can't remember if I might have done something to break it since.
Also "window" would be a pointer to the window that you want to receive the drop....I guess this could probably be made to be a parameter of the dnd_check function: function dnd_check(window)

07-17-2008 10:43 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #6
RE: drag 'n drop from external applications?

Well the docs say that...

"FL_DND_* events cannot be used in widgets derived from Fl_Group or Fl_Window."

They should work with Fl_Box though. However I still can't get the box to want to accept the dnd event.

07-17-2008 03:04 PM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #7
RE: drag 'n drop from external applications?

Weird ... I thought I had replied to this ...

I am pretty sure I know why it is not working, the DND events are probably being discarded (although they are definitely fired). If you create a window with a entry field you will see that you can drag anything to it, and then you could have a timer that checks if it's value has changed (I'll post an example in a second).

As far as trapping the DND_* (and other system events), I have implemented the event handler callback, which allows you to create a callback that responds to all events not being trapped elsewhere (including system/X events). I haven't had a chance to test this with DND events yet, but it'll should allow you to write more sensible code for these cases.

I'll push it out with the next build (hopefully this weekend).

Cheers
JohnM

07-17-2008 10:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #8
RE: drag 'n drop from external applications?

JohnMurga Wrote:
If you create a window with a entry field you will see that you can drag anything to it, and then you could have a timer that checks if it's value has changed (I'll post an example in a second).


Do you still have that example handy? Also I can't seem to find the event_detection.lua demo in the examples directory.

07-18-2008 11:55 PM
Find all posts by this user Quote this message in a reply
MrBill
Junior Member
**


Posts: 14
Group: Registered
Joined: Mar 2008
Status: Offline
Reputation: 0
Post: #9
RE: drag 'n drop from external applications?

dvw86 Wrote:
Also I can't seem to find the event_detection.lua demo in the examples directory.


Hmm I thought I replied to this thread last night.
I think you mean this event_detection available at the murgalua gallery

07-20-2008 07:58 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #10
RE: drag 'n drop from external applications?

Thanks!

07-20-2008 05:23 PM
Find all posts by this user Quote this message in a reply
Pages (2): « First [1] 2 Next > Last »
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: