psiberx / cp2077-codeware

Cyberpunk 2077 library and framework for creating script mods.
MIT License
71 stars 12 forks source link

Compilation error: cannot Reparent an inkComponent #8

Closed poirierlouis closed 1 year ago

poirierlouis commented 1 year ago

Hi,

I'm trying to play with your framework. Based on this section in wiki, I can create a custom inkComponent as a widget. When I want to add it in the tree using Reparent, the following error is shown in compilation logs:

[NO_MATCHING_OVERLOAD] group.Reparent(other); ^^^^^^^^^^^^^^ arguments passed to Reparent do not match any of the overloads: 1st argument: expected wref\<inkCompoundWidget>, given ref\<MyOtherComponent>

Here parts of the code:

public class MyOtherComponent extends inkComponent {
  // ...
}

public class MyComponent extends inkComponent {
  // ...

  protected cb func OnCreate() -> ref<inkWidget> {
    let root = new inkCanvas();

    root.SetName(this.GetClassName());
    root.SetAnchor(inkEAnchor.Fill);
    let other = new MyOtherComponent();

    other.Reparent(root);
    let group = new inkVerticalPanel();

    group.SetName(n"group");
    group.SetAnchor(inkEAnchor.BottomCenter);
    group.SetAnchorPoint(new Vector2(0.5, 1.0));
    group.SetMargin(new inkMargin(8.0, 0.0, 8.0, 48.0));
    group.Reparent(other);  // <--- compilation error
    return root;
  }
}

According to the log, Reparent doesn't accept an inkComponent-like instance. Can I declare and how can I do so using inkComponent and reparent it among other widgets? Should I use the "old" inkCustomController approach I saw in your code and others?

Any guidance would be much appreciated :)

poirierlouis commented 1 year ago

My bad, I was trying to Reparent with an inkRectangle.