Problem with MouseUp Event on Sash [message #1613058] |
Thu, 12 February 2015 11:28 |
Maciej Gorski Messages: 4 Registered: October 2014 |
Junior Member |
|
|
Hi,
i am trying to recreate a scale widget by myself since the normal one is not adequate for my purpose because of the fixed size of the scale button. The Idea was to create a Composite with a Canvas containing the slider line and on top of it a Sash with the purpose of the scale button (Sash because of the nice looking drag visuals). Now i am stuck at the point where i added a mouseUp Event to the Sash and when i drag the widget to the right side it repositions itself perfectly but when i try to move him to the left side the mouseUp event isnt even fired. I tried multiple solutions like position the through FormAttachements and setBounds() but no success.
private void creCnvPlc(final int aHgt, final int aWdt){
cnvCnt = new Canvas( this, SWT.NONE );
cnvFrmDat = new FormData();
cnvFrmDat.left = new FormAttachment( 0, 0 );
cnvFrmDat.right = new FormAttachment( 100, 0 );
cnvFrmDat.top = new FormAttachment( 0, 0 );
cnvFrmDat.bottom = new FormAttachment( 100, 0 );
cnvFrmDat.height = aHgt;
cnvFrmDat.width = aWdt;
cnvCnt.setLayoutData( cnvFrmDat );
cnvCnt.addPaintListener( new PaintListener() {
@Override
public void paintControl( PaintEvent event ) {
final Display dsp = event.display;
final GC gc = event.gc;
gc.setLineWidth( 3 );
gc.setForeground( dsp.getSystemColor( SWT.COLOR_GRAY ) );
if ( isHorAlg() ) {
gc.drawLine( 0 , aHgt/2 , aWdt , aHgt/2 );
}else{
gc.drawLine( aWdt/2 , 0 , aWdt/2 , aHgt );
}
}
} );
cnvCnt.redraw();
}
private void creSasPlc(final int aHgt, final int aWdt){
if ( !isVrtAlg() ) {
wdgSas = new Sash( this, SWT.HORIZONTAL );
}else{
wdgSas = new Sash( this, SWT.VERTICAL );
}
sclFrmDat = new FormData(aWdt, SWT.DEFAULT);
Rectangle rtl = new Rectangle( 10, 0, 10, 64 );
wdgSas.setBounds( rtl );
wdgSas.setLayoutData( sclFrmDat );
wdgSas.setBackground( this.getDisplay().getSystemColor( SWT.COLOR_RED ) );
wdgSas.addMouseListener( new MouseAdapter() {
@Override
public void mouseUp( MouseEvent e ) {
Point p = new Point( e.x, e.y );
p = getDisplay().map( (Control) e.widget, Scl.this, p );
Rectangle rtl = new Rectangle( p.x, 0, 10, 64 );
wdgSas.setBounds( rtl );
}
} );
wdgSas.moveAbove( null );
}
I was thinking to add a clientlistener on JS side but if possible avoid stepping to far into custom widget. If someone has an Idea or solution it would be great.
Thx in advance
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02134 seconds