using wxhaskell 0.9.4 with wxGTK 2.4.2, the below code
renders black text on a white background in the entry
control, instead of red on white.
import Graphics.UI.WX
main = start $
do f <- frame []
e <- entry f [text := "hello", textColor := red]
set f [layout := widget e]
textCtrlRich seems inconsistent, since
e <- textCtrlRich f [text := "foo", textColor := red]
renders black on white, but
e <- textCtrlRich f [textColor := red]
set e [text := "foo"]
renders red on white, as desired.
Logged In: YES
user_id=1015006
Originator: NO
I reproduced the bug.
OS: Linux
WxHaskell: darcs-version (approximately 2008-02-24)
Wx-Haskell: WxGtk-2.6.3
Bug reproduced on darcs tip (0.12.5)
A couple of points worth making about the sample code, since there is a real bug here, but the provided sample does not show up the problem.
> textCtrlRich seems inconsistent, since
> e <- textCtrlRich f [text := "foo", textColor := red]
>
> renders black on white, but
>
> e <- textCtrlRich f [textColor := red]
> set e [text := "foo"]
>
> renders red on white, as desired.
This is actually the expected behaviour. Using the textColor attribute sets only the text colour for *subsequently* inserted text, and does not set all of the text to the same colour (you need to do a textCtrlSetSelection to select all text and then textCtrlSetStyle to change it).
If you think about it, this is sensible given that rich text controls support text in many colours at once.
However, and this is less obvious,
t1 <- textCtrlRich f [textColor := red, text := "should be red"]
t2 <- textCtrlRich f []
set t2 [textColor := red, text := "should be red"]
Behaves differently for control t1 (which gets black text) and t2 (which correctly colours red).
The reason is deeply embedded in the implementation of textCtrlEx, which creates all text controls, but the bottom line is that it does not respect the ordering of *some* of the initial properties. In particular, the initial text is applied to the control before any other any other properties.
This is a bug, as you would expect supplied properties to be applied in order.
Fixed in local darcs, pending commit
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).