Mercurial > projects > dwt-addons
diff dwtx/jface/window/ToolTip.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 5df4896124c7 |
children | 04b47443bb01 |
line wrap: on
line diff
--- a/dwtx/jface/window/ToolTip.d Sun Jun 22 22:57:31 2008 +0200 +++ b/dwtx/jface/window/ToolTip.d Sun Jul 06 23:30:07 2008 +0200 @@ -65,7 +65,7 @@ /** * Don't recreate the tooltip as long the mouse doesn't leave the area - * triggering the Tooltip creation + * triggering the tooltip creation */ public static const int NO_RECREATE = 1 << 1; @@ -123,11 +123,14 @@ this.listener = new ToolTipOwnerControlListener(); this.shellListener = new class Listener { public void handleEvent(Event event) { - if( control_ !is null && ! control_.isDisposed() ) { + if( control_ !is null + && ! control_.isDisposed() ) { control_.getDisplay().asyncExec( dgRunnable( (Event event_){ - // Check if the new active shell is the tooltip itself + // Check if the new active shell is the tooltip + // itself if( control_.getDisplay().getActiveShell() !is CURRENT_TOOLTIP) { toolTipHide(CURRENT_TOOLTIP, event_); + } }, event)); } @@ -140,7 +143,7 @@ } /** - * Restore arbitary data under the given key + * Restore arbitrary data under the given key * * @param key * the key @@ -170,8 +173,10 @@ /** * Set the shift (from the mouse position triggered the event) used to - * display the tooltip. By default the tooltip is shifted 3 pixels to the - * left + * display the tooltip. + * <p> + * By default the tooltip is shifted 3 pixels to the right. + * </p> * * @param p * the new shift @@ -191,6 +196,7 @@ control.addListener(DWT.MouseMove, listener); control.addListener(DWT.MouseExit, listener); control.addListener(DWT.MouseDown, listener); + control.addListener(DWT.MouseWheel, listener); } /** @@ -202,10 +208,11 @@ control.removeListener(DWT.MouseMove, listener); control.removeListener(DWT.MouseExit, listener); control.removeListener(DWT.MouseDown, listener); + control.removeListener(DWT.MouseWheel, listener); } /** - * Return whther the tooltip respects bounds of the display. + * Return whether the tooltip respects bounds of the display. * * @return <code>true</code> if the tooltip respects bounds of the display */ @@ -228,7 +235,7 @@ } /** - * Return whther the tooltip respects bounds of the monitor. + * Return whether the tooltip respects bounds of the monitor. * * @return <code>true</code> if tooltip respects the bounds of the monitor */ @@ -254,7 +261,7 @@ /** * Should the tooltip displayed because of the given event. * <p> - * <b>Subclasses may overwrite this to get custom behaviour</b> + * <b>Subclasses may overwrite this to get custom behavior</b> * </p> * * @param event @@ -369,7 +376,8 @@ // the cursor.x is inside the tip Point cursorLocation = tip.getDisplay().getCursorLocation(); - if( cursorLocation.y is location.y && location.x < cursorLocation.x && location.x + size.x > cursorLocation.x ) { + if (cursorLocation.y is location.y && location.x < cursorLocation.x + && location.x + size.x > cursorLocation.x) { location.y -= 2; } @@ -445,66 +453,59 @@ if (tip !is null && !tip.isDisposed() && shouldHideToolTip(event)) { control.getShell().removeListener(DWT.Deactivate, shellListener); currentArea = null; - passOnEvent(tip,event); + passOnEvent(tip, event); tip.dispose(); CURRENT_TOOLTIP = null; afterHideToolTip(event); } } - private void passOnEvent(Shell tip,Event event) { - if ( control !is null && ! control.isDisposed() && event !is null && event.widget !is control && event.type is DWT.MouseDown) { + private void passOnEvent(Shell tip, Event event) { + if (control !is null && !control.isDisposed() && event !is null + && event.widget !is control && event.type is DWT.MouseDown) { Display display = control.getDisplay(); Point newPt = display.map(tip, null, new Point(event.x, event.y)); Event newEvent = new Event(); - newEvent.button=event.button; - newEvent.character=event.character; + newEvent.button = event.button; + newEvent.character = event.character; newEvent.count = event.count; - newEvent.data=event.data; - newEvent.detail=event.detail; - newEvent.display=event.display; - newEvent.doit=event.doit; - newEvent.end=event.end; - newEvent.gc=event.gc; - newEvent.height=event.height; - newEvent.index=event.index; - newEvent.item=event.item; - newEvent.keyCode=event.keyCode; - newEvent.start=event.start; - newEvent.stateMask=event.stateMask; - newEvent.text=event.text; - newEvent.time=event.time; - newEvent.type=event.type; - newEvent.widget=event.widget; - newEvent.width=event.width; + newEvent.data = event.data; + newEvent.detail = event.detail; + newEvent.display = event.display; + newEvent.doit = event.doit; + newEvent.end = event.end; + newEvent.gc = event.gc; + newEvent.height = event.height; + newEvent.index = event.index; + newEvent.item = event.item; + newEvent.keyCode = event.keyCode; + newEvent.start = event.start; + newEvent.stateMask = event.stateMask; + newEvent.text = event.text; + newEvent.time = event.time; + newEvent.type = event.type; + newEvent.widget = event.widget; + newEvent.width = event.width; newEvent.x = newPt.x; newEvent.y = newPt.y; tip.close(); - display.asyncExec(new class(display,newEvent) Runnable { - Display display_; - Event newEvent_; - this( Display a, Event b ){ - display_=a; - newEvent_=b; + display.asyncExec(dgRunnable( delegate(Display display_, Event newEvent_) { + if (IS_OSX) { + try { + Thread.sleep(0.300); + } catch (InterruptedException e) { + + } + + display_.post(newEvent_); + newEvent_.type = DWT.MouseUp; + display_.post(newEvent_); + } else { + display_.post(newEvent_); } - public void run() { - if( IS_OSX ) { - try { - Thread.sleep(0.300); - } catch (InterruptedException e) { - - } - - display_.post(newEvent_); - newEvent_.type = DWT.MouseUp; - display_.post(newEvent_); - } else { - display_.post(newEvent_); - } - } - }); + }, display,newEvent)); } } @@ -583,7 +584,7 @@ Composite parent); /** - * This method is called after a Tooltip is hidden. + * This method is called after a tooltip is hidden. * <p> * <b>Subclasses may override to clean up requested system resources</b> * </p> @@ -674,6 +675,7 @@ case DWT.KeyDown: case DWT.MouseDown: case DWT.MouseMove: + case DWT.MouseWheel: toolTipHide(CURRENT_TOOLTIP, event); break; case DWT.MouseHover: @@ -681,7 +683,7 @@ break; case DWT.MouseExit: /* - * Check if the mouse exit happend because we move over the + * Check if the mouse exit happened because we move over the * tooltip */ if (CURRENT_TOOLTIP !is null && !CURRENT_TOOLTIP.isDisposed()) {