[sedonadev] fire code if Comp is in kit

65 views
Skip to first unread message

keith bradley

unread,
Jun 8, 2017, 7:20:05 PM6/8/17
to sedo...@googlegroups.com
Good afternoon all Sedona peeps!

This code in the if block never fires even though my comp is surly in the kit:
The else block code always fires.



virtual override int linkEvent(int eType, Link link)
{

  Component cLinked = Sys.app.lookup(link.fromComp)

if (Sys.type(Sys.findKit("myKit").id, link.fromComp) != null)
{
  if (eType == ADDED)
  {
  // when a link is added ... code here never gets run even though the comp is in the kit.
  return 0
}
  else // REMOVED
  {
      // also when a link is deleted ... code here never gets run even though the comp is in the kit.
      return 0
  }
  }
  else
  // code here always runs which prints a debug message to stdout.
  return 0
}

Murat Egrikavuk

unread,
Jun 9, 2017, 3:45:32 AM6/9/17
to sedo...@googlegroups.com

link.fromComp id represents a component Id.
Sys.type(...) method needs to be fed the typeId of that component.
You could try link.fromComp.type.id

But that won't achieve what you want either. For example link.fromComp.type.id might be returning an id of 1. Your kit has a component with an id of 1. But so do other kits in the schema. So your call to Sys.type(...) method may return a value even if the link is not from a component in your kit.

You could perhaps try
if ( Sys.findKit("myKit").id == link.fromComp.type.kit.id
--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+...@googlegroups.com.
To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.



keith bradley

unread,
Jun 9, 2017, 1:41:40 PM6/9/17
to sedo...@googlegroups.com
Thanks Murat !!!

To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.

keith bradley

unread,
Jun 9, 2017, 9:28:52 PM6/9/17
to sedo...@googlegroups.com

I got a kit compile error of:

unknown field: short.type

I assumed I had to cast:

((Component)link.fromComp).type.kit.id

... but I got:

Expr type short cannot be cast as sys::Component

So I tried a new approach:

Kit.type(link.fromComp).kit.id

which yielded:

Cannot call instance method sys::Kit.type in static context.

I am at my whit's end.



keith bradley

unread,
Jun 9, 2017, 10:13:43 PM6/9/17
to sedo...@googlegroups.com
Once I had lost all my whits ... I figured it out:

if (Sys.findKit("myKit").id == cLinked.type.kit.id)

Reply all
Reply to author
Forward
0 new messages