Results 1 to 6 of 6

Thread: GUILabel Color

  1. #1

    Default GUILabel Color

    Hey,

    I'm trying to change and update the TextColor of a GUILabel (instead of an image) but my code makes the label invisible altogether. Is there a setting i'm missing? This is my code.

    Code:
    class MyConfig extends GUICustomPropertyPage;
    
    //various colour variables, mosliders etc...
    
    function bool InternalDraw(Canvas Canvas)
    {
    	local color TestColor;
             
            //initially I only set currentColour.TextColor but i've since added the other code in a vain attempt to get the colour working.
            //I've also tried setting the style to STY_Normal.
    	if(Canvas != None)
    	{
    		TestColor.R = currentColourR.GetValue();
    		TestColor.G = currentColourG.GetValue();
    		TestColor.B = currentColourB.GetValue();
    		TestColor.A = 255;
    		Canvas.Reset();
    		Canvas.DrawColor = TestColor;
    		currentColour.TextColor = TestColor;
    	}
    
    	return true;
    }
    
    defaultproperties
    {
         Begin Object Class=GUILabel Name=MyColour
             StyleName="TextLabel"
             Caption="My Color:"
             WinWidth=0.181976
    	 WinHeight=0.033333
    	 WinLeft=0.334867
    	 WinTop=0.255355
             RenderWeight=0.200000
             OnDraw=InternalDraw
         End Object
         currentColour=MyColour
    }
    Thanks for any help, ideas or suggestions!

  2. #2

    Default

    I seemed to have solved it. It seems setting OnDraw to a component makes it invisible. I used a second invisible label to call the InternalDraw function and update the colours from there. :S

  3. #3

    Default

    Keep in mind that On(Pre)Draw returns a boolean. The default implementation returns false to keep the built-in drawing stuff working. You return true, which means you want to handle all the drawing logic yourself.
    Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives

    <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
    <TNSe> nono
    <TNSe> its always funny to find code a week later you dont even remember writing
    <Pfhoenix> what's worse is when you have a Star Wars moment
    <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
    Note that your questions via PMs will be ignored if they actually belong in the forum.

  4. #4

    Default

    Thank you Wormbo, very informative and it explains the behaviour of the components.

  5. #5

    Default

    Here's a suggestion:

    Change the TextColor variable of the Label when one of the Slider's value has changed.
    Makes more sense than updating the color variable on every drawing call.

  6. #6

    Default

    My way the value is constantly updated and you can see the colour change as the user moves the slider up and down (otherwise the colour would jump and not blend nicely).


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.