This project is read-only.

Is it possible to conditionally cancel a shape during a displaying / creating event?

Topics: Core, Writing modules
Jun 23, 2012 at 10:49 PM
Edited Jun 23, 2012 at 10:51 PM

I'm sure most of us have been there: you're eating a sandwhich, and suddenly you ask yourself: is it possible to prevent a shape from rendering based on a certain condition? Just as if you put "-" or "Nowhere" in for that particular shape, only this time you want the shape to either render or not based on some application specific condition. For example:

public class SubtitleFieldShapeAlteration : ShapeDisplayEvents {

        public override void Displaying(ShapeDisplayingContext context) {
            if (context.Shape.ContentField.Name == "MyFieldName")
                if (aCertainCondition == True) {
                    // Somehow instruct the shape or the display manager to *not* render the shape


Now I could easily add some code to the shape template to not render a thing, but since that template can be overridden in a theme, I don't want to have the theme developer to duplicate my logic that decides wether or not the shape should be displayed.

I should add that I do not create this shape myself: it's a shape created by some TextFieldDriver.


Jun 26, 2012 at 7:31 AM

Sure, send it to a zone that never gets rendered for example.

Jun 26, 2012 at 1:03 PM

Oh yes, thanks! That's why I didn't think of it myself: too simple a solution :)