Page 1 of 1

Signaling Events from a Tile Item

Posted: Wed Mar 07, 2018 3:55 am
by jyoung
I have a Tile Item that contains a button. I would like to bubble up the button's click event (via signal) to up to the parent component like the PRIM_TILE.ItemClick event.

I've defined a "Remove" event in the Tile, but I can't subscribe to it.

This gives me an error stating PRIM_TILE<MYTILEP01> does not contain an event REMOVE.

Code: Select all

evtroutine handling(#MyTiles.Remove)
* trigger deletion
endroutine
Ok, I understand that, as the event is on MYTILEP01 not on PRIM_TILE.

I've also tried using the iterator such as MyTiles<>.Remove but that gives me the "Expression is not an iterator" error.

How do you signal events up from a Tile?

I think I could do this with an application scoped object, but is there a way to do it with one?

Thanks,
Joe

Re: Signaling Events from a Tile Item

Posted: Wed Mar 07, 2018 8:56 am
by GregSippel
Joe,

In order to get a reference to the tile item design, I think (as I haven't tested it yet) you need the following,

1) In component that has the PRIM_TILE defined in it create a global variable that is dynamic that is the same class as the item design, such as

Define_com Class(#YourTileDesign) Name(#ActiveTile) Reference(*DYNAMIC)

2) Since the user will need to move the mouse over the tile design to get to the button you can the ItemMouseEnter event of the PRIM_TILE to capture the needed reference, like this

Evtroutine Handling(#TileControl.ItemMouseEnter)

#ActiveTile <= (#TileControl.CurrentItem.Design *As #YourTileDesign)

Endroutine

3) You should be able to hear the events in the component that contains the PRIM_TILE by doing

Evtroutine Handling(#ActiveTile.YourEvent)

* Actions for Event

Endroutine

The same technique should enable to also call methods directly as well. Also, you can consider using a collection of the item design if you wish to call a method in all of them, so as you are adding Tile Items to the PRIM_TILE you would do the following

#YourTileDesignsCollection.Insert( (#TileControl.CurrentItem.Design *As #YourTileDesign) )

This means you can now do things like

#YourTileDesignsCollection<>.Remove

Hope this helps

Cheers
Greg

Re: Signaling Events from a Tile Item

Posted: Thu Mar 08, 2018 1:30 am
by jyoung
Brilliant. Both techniques work well.

I was struggling with getting a hold of the reference, did not thing to capture it in the mouse over. Tried it with Focus and that seems to work too.

Thanks!
Joe