getName() component that is active



I am trying to find out the component name of the current component that is active and visible in the window through setContentComponent. I thought that the function getName would be the right one, but it is returning an empty string.

My usage is as follows:

String componentName = getName();
String text = T(“Blah”);
printf(“component name: %s\n”,componentName.toUTF8());
printf(“Testing: %s\n”,text.toUTF8());

I know I am printing to STDOUT correctly, I just don’t know how I am missing the usage of getName() to find the component that is active and visible.

Any help appreciated.


Folks, never mind, I found the answer. You first have to define a name for the active component for the window with setName(). Then getName() will return the text.


U can give the name to the component while creating it. Check the constructor of the component class.