#2459 TabPane.onSelect() in Javascript

SlimerDude Thu 10 Sep 2015

Hi, when switching tabs in a TabPane, the Javascript version currently does not fire a select event as per onSelect(). This patch adds the functionality in.

diff -r a77e9070251b src/fwt/js/TabPeer.js
--- a/src/fwt/js/TabPeer.js	Fri Sep 04 09:11:51 2015 -0400
+++ b/src/fwt/js/TabPeer.js	Thu Sep 10 22:10:28 2015 +0100
@@ -40,6 +40,13 @@
   {
     $self.m_parent.peer.m_selectedIndex = $self.peer.index;
     $self.m_parent.relayout();
+
+    var evt  = fan.fwt.Event.make();
+    evt.m_id = fan.fwt.EventId.m_select;
+    evt.m_widget = self;
+    evt.m_index  = $self.peer.index;
+    evt.m_data   = $self;
+    $self.m_parent.onSelect().fire(evt);
   }
 
   var css = elem.style;

SlimerDude Fri 11 Sep 2015

In Java land, when setting a selected tab the display also updates to reflect the change. Currently in Javascript land, changing the selected tab just updates a number somewhere, and the screen is left untouched.

Apply this little patch to have the TabPane re-draw and update itself:

diff -r a77e9070251b src/fwt/js/TabPanePeer.js
--- a/src/fwt/js/TabPanePeer.js	Fri Sep 04 09:11:51 2015 -0400
+++ b/src/fwt/js/TabPanePeer.js	Fri Sep 11 08:52:36 2015 +0100
@@ -13,7 +13,7 @@
 fan.fwt.TabPanePeer.prototype.$ctor = function(self) {}
 
 fan.fwt.TabPanePeer.prototype.selectedIndex = function(self) { return this.m_selectedIndex; }
-fan.fwt.TabPanePeer.prototype.selectedIndex$ = function(self, val) { this.m_selectedIndex = val; }
+fan.fwt.TabPanePeer.prototype.selectedIndex$ = function(self, val) { this.m_selectedIndex = val; self.relayout(); }
 fan.fwt.TabPanePeer.prototype.m_selectedIndex = 0;
 
 fan.fwt.TabPanePeer.prototype.sync = function(self)

andy Mon 21 Sep 2015

Both fixed

Login or Signup to reply.