Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Problem with MouseUp Event on Sash
Problem with MouseUp Event on Sash [message #1613058] Thu, 12 February 2015 11:28 Go to next message
Maciej Gorski is currently offline Maciej GorskiFriend
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
Re: Problem with MouseUp Event on Sash [message #1613112 is a reply to message #1613058] Thu, 12 February 2015 12:13 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
you could try Sash Selection event instead of MouseUp. If you need the
mouse position in selection event use Display.getCursorLocation and map
it to the Sash.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Problem with MouseUp Event on Sash [message #1613268 is a reply to message #1613112] Thu, 12 February 2015 14:37 Go to previous message
Maciej Gorski is currently offline Maciej GorskiFriend
Messages: 4
Registered: October 2014
Junior Member
I changed it to

		wdgSas.addSelectionListener( new SelectionAdapter() {
			@Override
			public void widgetSelected( SelectionEvent e ) {
				Point orgP = wdgSas.getLocation();
				Point evtP = new Point( e.x, e.y );
				
				if ( isHorFlg ) {
					if ( (orgP.x > evtP.x) || (orgP.x < evtP.x)  ) {
						evtP = getDisplay().map( (Control) e.widget, Scl.this, evtP );
						int resPos = evtP.x - orgP.x;
						Rectangle rtl = new Rectangle( resPos, 0, 10, 64 );
						wdgSas.setBounds( rtl );
					}
				}
			}
		} );


now it works fine thx for the idea Very Happy
Previous Topic:How to show a Progress bar while waiting for the server's response?
Next Topic:EMF RAP editor fails to start; bundle resolution failure
Goto Forum:
  


Current Time: Tue Mar 19 10:10:36 GMT 2024

Powered by FUDForum. Page generated in 0.02134 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top