Menu

#19 textColor attribute does not appear to work (correctly?)

confirmed
closed-fixed
None
5
2010-06-04
2005-06-21
Anonymous
No

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.

Discussion

  • Eric Kow

    Eric Kow - 2008-02-18
    • milestone: --> 809567
     
  • Mads Lindstrřm

    Mads Lindstrřm - 2008-02-24

    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

     
  • Mads Lindstrřm

    Mads Lindstrřm - 2008-02-24
    • milestone: 809567 --> 276183
     
  • Mads Lindstrřm

    Mads Lindstrřm - 2008-02-24
    • milestone: 276183 --> confirmed
     
  • Jeremy O\'Donoghue

    • assigned_to: nobody --> jodonoghue
    • status: open --> pending-accepted
     
  • Jeremy O\'Donoghue

    Bug reproduced on darcs tip (0.12.5)

     
  • Jeremy O\'Donoghue

    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.

     
  • Jeremy O\'Donoghue

    Fixed in local darcs, pending commit

     
  • Jeremy O\'Donoghue

    • status: pending-accepted --> pending-fixed
     
  • SourceForge Robot

    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).

     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.