google-code-export / ulipad

Automatically exported from code.google.com/p/ulipad
0 stars 0 forks source link

unable to middle mouse click to close the inactive file #184

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open more than one files, assume a, b, c
2. When c is active, move mouse to the tab of b
3. middle click the tab b.

What is the expected output? What do you see instead?
The expected output is tab b is closed. Instead, tab c is closed

What version of the product are you using? On what operating system?
svn version, windows vista.

Please provide any additional information below.

Original issue reported on code.google.com by sunyi...@gmail.com on 21 Apr 2009 at 11:37

GoogleCodeExporter commented 9 years ago
# FlatNotebook itself works for middle moulse click to close the tab
# in a quick script test
import wx
from modules.wxctrl import FlatNotebook as FNB
w = wx.Frame(win)

stil = FNB.FNB_SMART_TABS|FNB.FNB_VC8|FNB.FNB_X_ON_TAB| \
    FNB.FNB_NO_X_BUTTON|FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS

book = FNB.FlatNotebook(w, wx.ID_ANY,  style=stil)
p=wx.Panel (w, -1)
book.AddPage(wx.Panel (w, -1), 'aaa',True, -1)
book.AddPage(wx.Panel (w, -1), 'bbb', True, -1)
book.AddPage(p, 'ccc', True, -1)

w.SetSize((700,600))
w.Show()

Original comment by sunyi...@gmail.com on 15 Aug 2009 at 5:58

GoogleCodeExporter commented 9 years ago
made a fix, but not perfect, as it will change the selection to where mouse is.

Index: EditorFactory.py
===================================================================
--- EditorFactory.py    (revision 504)
+++ EditorFactory.py    (working copy)
@@ -371,7 +371,8 @@
     def OnClose(self, event):
         if not self.skip_closing:
             event.Veto()
-            wx.CallAfter(self.mainframe.CloseFile, self.document)
+            document = self.getDoc(event.GetSelection())
+            wx.CallAfter(self.mainframe.CloseFile, document)
         else:
             event.Skip()
         self.skip_closing = False

Original comment by sunyi...@gmail.com on 16 Aug 2009 at 2:39

GoogleCodeExporter commented 9 years ago
Thank you very much. I've fixed it.

Original comment by limo...@gmail.com on 16 Aug 2009 at 6:48

GoogleCodeExporter commented 9 years ago
This is the code that perfects the page focus after middle mouse. I.E. when 
middle 
mouse clicked on the inactive tab, that tab will be closed, but the focus stays 
at 
the active page, no switch.

Index: EditorFactory.py
===================================================================
--- EditorFactory.py    (revision 511)
+++ EditorFactory.py    (working copy)
@@ -343,16 +343,20 @@
         except:
             return
         self.callplugin('beforeclosefile', self, document)
+        selected = self.GetSelection()        
         self.skip_closing = True
         self.skip_page_change = True
         self.DeletePage(index)
-        if index >= len(self.getDocuments()):
-            index = len(self.getDocuments())-1
-        if index >= 0:
-            self.switch(self.getDoc(index))
-        else:
-            self.new()
-        self.document.SetFocus()
+        #if the page to close is not selected, no need to switch page
+        if index == selected: 
+            if index > 0:
+                if index >= len(self.getDocuments()):
+                    index = len(self.getDocuments())-1
+                # only swith page when there is a page to switch to
+                self.switch(self.getDoc(index))
+            else:
+              self.new()
+            self.document.SetFocus()
         self.callplugin('afterclosefile', self)

     def savefile(self, document, filename, encoding):

Original comment by sunyi...@gmail.com on 16 Aug 2009 at 10:56

GoogleCodeExporter commented 9 years ago
It works. Thank you.

Original comment by limo...@gmail.com on 17 Aug 2009 at 12:44