Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for unexpected TextCtrl behaviour on OS X. This is the equivalent…

… of patch f225d0c on master.
  • Loading branch information...
commit d2646f79bf9cd18f9eaa888a9dcda961f672bfa3 1 parent c31ca7c
@jodonoghue authored
View
24 wx/src/Graphics/UI/WX/Controls.hs
@@ -76,6 +76,7 @@ import Graphics.UI.WX.Window
import Control.Monad (forM_)
import Data.Dynamic -- for "alignment"
+import System.Info (os)
defaultStyle
@@ -314,15 +315,27 @@ instance Able (TextCtrl a) where
= newAttr "enabled" textCtrlIsEditable textCtrlSetEditable
-}
+-- Workaround for Unexpected TextCtrl behaviour (https://github.com/jodonoghue/wxHaskell/issues/1#issuecomment-5202439)
+-- Problem arises from the fact that wxTE_RICH is needed only on Windows platforms, but is essential there. However, on
+-- wxMac > 2.9, wxTE_RICH seems not to be ignored as the documentation claims.
+getRichTE = if (os == "mingw32") || (os == "win32")
+ then wxTE_RICH
+ else 0
+
+getRichTE2 = if (os == "mingw32") || (os == "win32")
+ then wxTE_RICH2
+ else 0
+
-- | Create a single-line text entry control. Note: 'alignment' has to
-- be set at creation time (or the entry has default alignment (=left) ).
+-- This is an alias for textEntry
--
-- * Instances: 'Wrap', 'Aligned', 'Commanding' -- 'Textual', 'Literate', 'Dimensions', 'Colored', 'Visible', 'Child',
-- 'Able', 'Tipped', 'Identity', 'Styled', 'Reactive', 'Paint'.
--
entry :: Window a -> [Prop (TextCtrl ())] -> IO (TextCtrl ())
entry parent props
- = textCtrlEx parent wxTE_RICH props
+ = textCtrlEx parent getRichTE props
-- | Create a single-line text entry control. Note: 'alignment' has to
-- be set at creation time (or the entry has default alignment (=left) ).
@@ -332,7 +345,7 @@ entry parent props
--
textEntry :: Window a -> [Prop (TextCtrl ())] -> IO (TextCtrl ())
textEntry parent props
- = textCtrlEx parent wxTE_RICH props
+ = textCtrlEx parent getRichTE props
-- | Create a multi-line text control. Note: the 'wrap' and 'alignment'
-- have to be set at creation time or the default to 'WrapNone' and 'AlignLeft' respectively.
@@ -342,7 +355,7 @@ textEntry parent props
--
textCtrl :: Window a -> [Prop (TextCtrl ())] -> IO (TextCtrl ())
textCtrl parent props
- = textCtrlEx parent (wxTE_MULTILINE .+. wxTE_RICH) props
+ = textCtrlEx parent (wxTE_MULTILINE .+. getRichTE) props
-- | Create a multi-line text rich-text control with a certain wrap mode
@@ -355,7 +368,7 @@ textCtrl parent props
--
textCtrlRich :: Window a -> [Prop (TextCtrl ())] -> IO (TextCtrl ())
textCtrlRich parent props
- = textCtrlEx parent (wxTE_MULTILINE .+. wxTE_RICH2) props
+ = textCtrlEx parent (wxTE_MULTILINE .+. getRichTE2) props
-- | Create a generic text control given a certain style.
--
@@ -366,9 +379,10 @@ textCtrlEx :: Window a -> Style -> [Prop (TextCtrl ())] -> IO (TextCtrl ())
textCtrlEx parent stl props
= feed2 props stl $
initialWindow $ \id rect ->
+ initialText $ \txt ->
initialWrap $
initialAlignment $ \props flags ->
- do e <- textCtrlCreate parent id "" rect flags
+ do e <- textCtrlCreate parent id txt rect flags
set e props
return e
View
2  wx/src/Graphics/UI/WX/Window.hs
@@ -131,7 +131,7 @@ instance Textual (Window a) where
= ifInstanceOf w classComboBox
(\cb -> (comboBoxGetValue cb, \s -> do comboBoxClear cb; comboBoxAppend cb s)) $
ifInstanceOf w classTextCtrl
- (\tc -> (textCtrlGetValue tc, \s -> do textCtrlClear tc; textCtrlWriteText tc s)) $
+ (\tc -> (textCtrlGetValue tc, \s -> do textCtrlChangeValue tc s)) $
(windowGetLabel w,windowSetLabel w)
appendText w s
View
4 wx/wx.cabal
@@ -1,5 +1,5 @@
Name: wx
-Version: 0.13.2.2
+Version: 0.13.2.3
License: OtherLicense
License-file: license.txt
Homepage: http://haskell.org/haskellwiki/WxHaskell
@@ -24,7 +24,7 @@ Flag newBase
Library
if flag(splitBase)
- build-depends: wxcore >= 0.13.1 && < 0.90,
+ build-depends: wxcore >= 0.13.2.3 && < 0.90,
stm
if flag(newBase)
build-depends:
View
5 wxcore/src/cpp/eljtextctrl.cpp
@@ -20,6 +20,11 @@ EWXWEXPORT(void,wxTextCtrl_SetValue)(wxTextCtrl* self,wxString* value)
self->SetValue(*value);
}
+EWXWEXPORT(void,wxTextCtrl_ChangeValue)(wxTextCtrl* self, wxString* value)
+{
+ self->ChangeValue(*value);
+}
+
EWXWEXPORT(int,wxTextCtrl_GetLineLength)(wxTextCtrl* self,long lineNo)
{
return self->GetLineLength(lineNo);
View
1  wxcore/src/include/wxc_glue.h
@@ -4538,6 +4538,7 @@ TBool wxTextCtrl_CanCut( TSelf(wxTextCtrl) _obj );
TBool wxTextCtrl_CanCopy( TSelf(wxTextCtrl) _obj );
TBool wxTextCtrl_CanCut( TSelf(wxTextCtrl) _obj );
TBool wxTextCtrl_CanPaste( TSelf(wxTextCtrl) _obj );
+TBool wxTextCtrl_CanRedo( TSelf(wxTextCtrl) _obj );
TBool wxTextCtrl_CanUndo( TSelf(wxTextCtrl) _obj );
void wxTextCtrl_ChangeValue( TSelf(wxTextCtrl) _obj, TClass(wxString) text );
void wxTextCtrl_Clear( TSelf(wxTextCtrl) _obj );
View
2  wxcore/wxcore.cabal
@@ -1,5 +1,5 @@
name: wxcore
-version: 0.13.2.2
+version: 0.13.2.3
license: OtherLicense
license-file: LICENSE
author: Daan Leijen
Please sign in to comment.
Something went wrong with that request. Please try again.