← Back to team overview

kicad-developers team mailing list archive

Re: PATCH: OS X copy/close bug fix

 

Le 13/07/2016 à 08:22, jp charras a écrit :
> Le 13/07/2016 à 02:26, Brano Panak a écrit :
>> as far as i can see in my version yes, this can be specified in wxFormBuilder as separate fields ID
>> and LABEL
>>
> 
> You cannot specify the label when using a wxStdDialogButtonSizer in wxFormBuilder.
> Using a wxStdDialogButtonSizer is a good practice, because it uses the look and feel of each
> platform to display these standard buttons.
> 
> 

@Brano,
Can you test this patch?
(Only the Dimension/grid dialog is patched in Pcbnew)

-- 
Jean-Pierre CHARRAS
=== modified file 'common/dialog_shim.cpp'
--- common/dialog_shim.cpp	2016-07-02 16:32:03 +0000
+++ common/dialog_shim.cpp	2016-07-13 16:36:45 +0000
@@ -112,6 +112,21 @@
     Center();
 }
 
+void DIALOG_SHIM::FixOSXCancelButtonIssue()
+{
+#ifdef  __WXMAC__
+    // A ugly hack to fix an issue on OSX: ctrl+c closes the dialog instead of
+    // copying a text if a  button with wxID_CANCEL is used in a wxStdDialogButtonSizer
+    // created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority
+    // to copy text standard accelerator, and the dlg is closed when trying to copy text
+    wxButton* button = dynamic_cast< wxButton* > ( wxWindow::FindWindowById( wxID_CANCEL, this ) );
+
+    if( button )
+        button->SetLabel( _( "Cancel" ) );
+#endif
+}
+
+
 // our hashtable is an implementation secret, don't need or want it in a header file
 #include <hashtables.h>
 #include <base_struct.h>        // EDA_RECT

=== modified file 'include/dialog_shim.h'
--- include/dialog_shim.h	2016-07-02 16:32:03 +0000
+++ include/dialog_shim.h	2016-07-13 16:20:23 +0000
@@ -108,6 +108,16 @@
      */
     void FinishDialogSettings();
 
+    /** A ugly hack to fix an issue on OSX:
+     * when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of
+     * copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer,
+     * when the dlg is created by wxFormBuilder:
+     * the label is &Cancel, and this accelerator key has priority
+     * to copy text standard accelerator, and the dlg is closed when trying to copy text
+     * this function do nothing on other platforms
+     */
+    void FixOSXCancelButtonIssue();
+
     std::string m_hash_key;     // alternate for class_map when classname re-used.
 
     // variables for quasi-modal behavior support, only used by a few derivatives.

=== modified file 'pcbnew/dialogs/dialog_set_grid.cpp'
--- pcbnew/dialogs/dialog_set_grid.cpp	2016-05-02 14:15:24 +0000
+++ pcbnew/dialogs/dialog_set_grid.cpp	2016-07-13 16:29:54 +0000
@@ -91,6 +91,8 @@
     m_TextPosXUnits->SetLabel( GetUnitsLabel( m_parent->m_UserGridUnit ) );
     m_TextPosYUnits->SetLabel( GetUnitsLabel( m_parent->m_UserGridUnit ) );
 
+    FixOSXCancelButtonIssue();
+
     GetSizer()->SetSizeHints( this );
     Fit();
     Centre();


Follow ups

References