Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Buschtöns2014-02-04 10:57:51 +0000
committerTim Buschtöns2014-02-04 10:57:51 +0000
commit422c3d246317ff3de4820ba67189e0354e500abc (patch)
tree4ede68db0781f42d21bd073a1e9ed5c1ac2f7f31
parenta3ff453452dd5f2d625ec934eaea9380197b2a2b (diff)
downloadorg.eclipse.rap.incubator.dropdown-422c3d246317ff3de4820ba67189e0354e500abc.tar.gz
org.eclipse.rap.incubator.dropdown-422c3d246317ff3de4820ba67189e0354e500abc.tar.xz
org.eclipse.rap.incubator.dropdown-422c3d246317ff3de4820ba67189e0354e500abc.zip
Ensure DropDown always fires client-side "Show" and "Hide" Events
Since the actual popup fired the "Show" event, and that widget is not made visible until there are items set, the Show event was not always fired if the DropDown instance itself was marked as visible.
-rw-r--r--bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js25
-rw-r--r--tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js19
2 files changed, 31 insertions, 13 deletions
diff --git a/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js b/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js
index a3e3529..2e8c2f5 100644
--- a/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js
+++ b/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js
@@ -91,7 +91,6 @@
this._.grid.addEventListener( "mousedown", onMouseDown, this );
this._.grid.addEventListener( "mouseup", onMouseUp, this );
this._.popup.addEventListener( "appear", onAppear, this );
- this._.popup.addEventListener( "disappear", onDisappear, this );
this._.popup.getFocusRoot().addEventListener( "changeFocusedChild", onFocusChange, this );
this._.parentFocusRoot = parent.getFocusRoot();
this._.parentFocusRoot.addEventListener( "changeFocusedChild", onFocusChange, this );
@@ -180,10 +179,13 @@
show : function() {
checkDisposed( this );
- if( !this._.visibility && !rwt.remote.EventUtil.getSuspended() ) {
- rap.getRemoteObject( this ).set( "visible", true );
+ if( !this._.visibility ) {
+ this._.visibility = true;
+ fireEvent.call( this, "Show" );
+ if( !rwt.remote.EventUtil.getSuspended() ) {
+ rap.getRemoteObject( this ).set( "visible", true );
+ }
}
- this._.visibility = true;
if( this._.items.length > 0 && this._.parent.isCreated() && !this._.popup.isSeeable() ) {
this._.grid.setFont( this._.parent.getFont() );
renderLayout.call( this );
@@ -196,10 +198,13 @@
hide : function() {
checkDisposed( this );
- if( this._.visibility && !rwt.remote.EventUtil.getSuspended() ) {
- rap.getRemoteObject( this ).set( "visible", false );
+ if( this._.visibility ) {
+ this._.visibility = false;
+ fireEvent.call( this, "Hide" );
+ if( !rwt.remote.EventUtil.getSuspended() ) {
+ rap.getRemoteObject( this ).set( "visible", false );
+ }
}
- this._.visibility = false;
this._.popup.setVisibility( false ); // makes it disappear immediately
this._.popup.setDisplay( false ); // forces the popup to appear after all parents are layouted
},
@@ -491,12 +496,6 @@
var onAppear = function( event ) {
// NOTE: widget absolute position can change without changing it's relative postion, therefore:
renderPosition.call( this );
- fireEvent.call( this, "Show" );
- };
-
- var onDisappear = function( event ) {
- fireEvent.call( this, "Hide" );
- //this._.parent.setFocused( true );
};
var onFocusChange = function( event ) {
diff --git a/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js b/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js
index 4a286b6..0010d58 100644
--- a/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js
+++ b/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js
@@ -621,6 +621,15 @@ rwt.qx.Class.define( "rwt.dropdown.DropDown_Test", {
assertEquals( 1, logger.getLog().length );
},
+ testAddShowListener_notifiesEventForEmptyItems : function() {
+ var logger = TestUtil.getLogger();
+ dropdown.addListener( "Show", logger.log );
+
+ showDropDown( [] );
+
+ assertEquals( 1, logger.getLog().length );
+ },
+
testRemoveShowListener : function() {
var logger = TestUtil.getLogger();
dropdown.addListener( "Show", logger.log );
@@ -641,6 +650,16 @@ rwt.qx.Class.define( "rwt.dropdown.DropDown_Test", {
assertEquals( 1, logger.getLog().length );
},
+ testAddHideListener_notifiesEventForEmptyItems : function() {
+ showDropDown( [] );
+ var logger = TestUtil.getLogger();
+ dropdown.addListener( "Hide", logger.log );
+
+ dropdown.hide();
+
+ assertEquals( 1, logger.getLog().length );
+ },
+
testRemoveHideListener : function() {
showDropDown();
var logger = TestUtil.getLogger();

Back to the top