Author Topic: TextSetVisible trouble  (Read 1493 times)

Djjammin

  • Guest
TextSetVisible trouble
« on: August 29, 2012, 11:54:17 am »
Hello All,

Probably a simple answer to this one. Basically if i use blah=TextAdd("blah"); then TextSetVisible(blah,0); it doesn't always make the text invisible. Especially if i call it in a different subroutine then i set it... can someone shed some light on this?

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: TextSetVisible trouble
« Reply #1 on: August 31, 2012, 08:52:27 am »
TextSetVisible() should always be setting the text's visibility.  Are you doing anything such as calling TextAdd() over and over (outside of AppMain(), maybe)?  If you are calling TextAdd() over and over again, you're most likely setting a text invisible but there are other instances of the same label still hanging around.

The code below puts a label on the screen and toggles its visibility:

Code: [Select]
#include "DragonFireSDK.h"

int MyText;
int MyFont;
int Visible=1;

int OnTouch(int id, int event, int x, int y)
{
    if (event==1)
    {
        if (Visible)
            Visible=0;
        else
            Visible=1;
   
        TextSetVisible(MyText,Visible);
    }
    return(id);
}

void AppMain()
{
    MyFont=FontAdd("Helvetica", "Regular", 20, 0x00FF00);
    MyText=TextAdd(0, 0, "Hello, world!", MyFont);
    TouchAdd(0,0,320,480,OnTouch,1);
}
 
void OnTimer()
{
}

void AppExit()
{

}

Please let me know if you have any trouble getting this code to work for you.

Cheers,
Tim Sommers
DragonFireSDK Team

Djjammin

  • Guest
Re: TextSetVisible trouble
« Reply #2 on: September 01, 2012, 03:55:42 am »
Hi Tim,

Thanks for this... yeah i have been calling it numerous times outside AppMain()... it's a big project and to be honest very messy....

this may sound stupid but if i called the TextAdd() 4 times, and then in one button put 4 statements of TextSetVisible(blah, 0); should that then make all the instances invisible?

Thanks

Jammin

 

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: TextSetVisible trouble
« Reply #3 on: September 05, 2012, 12:17:29 pm »
Yes, that's right.  Call TextSetVisible() for each label with the handle of the label and the visibility flag.
Tim Sommers
DragonFireSDK Team