greenhouse
a creative coding toolkit for spatial interfaces

Tag methods for Node objects

Append a tag (flag - technically, a string) to any interactive object, without need to subclass.

  • Tag ()
  • HasTag ()
  • UnTag ()

Example

#include "Greenhouse.h"

class TaggedText : public Text
{
public:
  TaggedText (const Str &t) : Text (t) { }

  void Travail ()
  { //conditional statement to set the text and remove "tag"
    if (HasTag ("tag"))
      { SetString("tagged");
        UnTag ("tag");
      }
  }
};

void Setup ()
{ //Create a Text instance and assign its Str
  TaggedText *t1 = new TaggedText ("hello, greenhouse");
  TaggedText *t2 = new TaggedText ("hello, greenhouse");

  //Put the Text at the center of the Feld
  t1 -> SlapOnFeld ();
  t2 -> SlapOnFeld ();
  // offset the second text a quarter up the feld.
  t2 -> IncTranslation (0.25 * Feld () -> Height () * Feld () -> Up ());

  //Append a tag "tag"
  t1 -> Tag ("tag");
}