[haiku-development] Re: Handling drag'n'drop off files from Tracker

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 10 Sep 2015 07:04:43 +0200

On Wed, Sep 09, 2015 at 11:54:00AM -0700, pete.goodeve@xxxxxxxxxxxx wrote:

On Wed, Sep 09, 2015 at 12:26:05PM +0200, Marcus Overhagen wrote:
On Wed, Sep 9, 2015 at 9:30 AM, Jessica Hamilton
<jessica.l.hamilton@xxxxxxxxx> wrote:
Hi,

I was just looking at code for Heidi, and noticed that it doesn't
handle dropping files on its window. But I see in the code that
MessageReceived() handles the case of B_REFS_RECEIVED [1]. Running
from Terminal, BHandler appears to be dumping the message, and the
opcode is 'DATA' [2]. Changing the case statement to 'DATA' indeed
makes dropping files on the window work, which seems like a bug to me,
but I don't know the BeAPI that well.

'DATA' is B_SIMPLE_DATA and can be handled similar to B_REFS_RECEIVED
if it contains "refs".

See for example
https://github.com/haiku/haiku/blob/master/src/apps/mediaplayer/MainWin.cpp

Normally, B_REFS_RECEIVED is sent when a Open file panel is closed,
and automatically invokes RefsReceived().

This doesn't happen for drag+drop, see
https://www.haiku-os.org/legacy-docs/bebook/TheInterfaceKit_MessageConstants.html

Also note the function 'msg->WasDropped()'. What I usually do is simply
change 'msg->what'
to B_REFS_RECEIVED if that returns true, and then pass it through the rest of
the usual
MessageReceived handling. (if the dropped item is from somewhere else than
the Tracker,
its contents wil just be ignored.)

In the case of Heidi, we will probably also want to accept other dropped
things, not just files. At least text clips come to mind, but also
possibly dragging stack trace entries or function names from Debugger or
ImageViewer and opening the matching source file at the correct
line/column.

--
Adrien.

Other related posts: