[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: Please Help: Detecting swt-composite via mouse-event

I find that it's easier to draw your entire canvas by hand than adding 
actual widgets (composites etc) that you can then drag and drop. By drawing, 
you can add all listeners and you have full control over the behavior of 
pretty much anything that goes on in that canvas. We built a gantt composite 
like this from scratch, where you can DND, resize events, and what-not, and 
it works without a hitch. I'm just giving you a tip, as it might prove being 
easier than having to deal with all kinds of widgets that have a mind of 
their own.

Emil

"Boris Munivrana" <bmunivrana@xxxxxx> wrote in message 
news:005662a44c002ba7544a65befe16ee14$1@xxxxxxxxxxxxxxxxxx
> Hi there,
>
> I need some help with this issue:
> I have to write an UI where the user is allowed to schedule appointments.
> Therefor, I sublcassed swt-canvas, wich draws a grid. My canvas is 
> embedded within a ScrolledComposite.
> Each appointment is represented by a subclass of Composite.
> I registered a MouseListener at the ScrolledComposite and thus enabling 
> the user to move the "appointments" ( a.k.a. one specific Composite which 
> i instantiated and passed over to the MouseListener of the 
> ScrolledComposite for testing purposes) to specified rows and columns.
> This works fine so far, but my code until now isn't anything more than a 
> raw sketch.
> Of course there is a need for my scheduler to notify which of the 
> composites has been "grabbed" with the mouse, e.g. when the mouse hovers 
> over it and a mousedown-event occurs.
> But I'm not able to do this, since I have to set the enabled()-property of 
> the canvas to "false" in order to have the ScrolledComposite's 
> mouselistener to react.
> And I cannot register a MouseTrackListener to the appointment-composites, 
> since they are direct children of the disabled canvas.
>
> So, basically, what I'm trying to accomplish is something like a chess 
> game, there's a grid and I want to let the user move the elements on the 
> "chess board".
>
> Any help (e.g. pseudo-code) would be great. The elements that have to be 
> involved are:
>
> 1) a canvas on which the grid is drawn
> 2) a scrolledcomposite which holds the canvas
> 3) several composites which represent an element that can be moved.
>
> Thanks,
>
> Boris Munivrana
>