Widget as a global variable type?


#1

I’m looking to construct a dialog (text edit) box that I can re-use between different text widgets to edit the text of those widgets. I so far can’t find a way to write the text back to the correct widget. I need a widget reference I think in a global variable. But also I could be wrong about my approach. Approach:

  1. Each widget I want to ‘edit’ either has a raised event or normal onClick event that sets the text on the textfield to This.text and opens the dialog as a layer (sort of normal CMS behavior)
  2. I would like to store the identity of This widget but can’t find the means to do it…
    3.I edit the text in the textarea field of the dialog
  3. Submitting the text would set the text on the original This widget to the text in the textarea field.

It’s like I need a global variable of type ‘widget’ to access the methods of widgets.


#2

You can do this via the .name property of any widget. First, name each widget uniquely. Then, when you want to set the widget reference, do so by setting the value of the global variable to the name of the widget. For example, if you have a widget named, “boxA” and clicking it would show your dialog, your actions for **OnClick” would be “Set value of OnLoadVariable to [[This.name]] ; Show MyDialog”.

For the Submit button of the dialog’s text field, you need a way to call a specific widget based on the value of OnLoadVariable. One way to do this is to “tickle” each possible widget and if their name matches the value of OnLoadVariable, update their text to the text in the dialog’s text field. The “tickle” can be any event which is not otherwise called, for example “Move by (0,0)” or “Rotate by 0 degrees”. Then each widget can have an OnMove event with a conditional case of “IF value of OnLoadVariable equals [[This.Name]] set text on This to [[LVAR1.text]]” where LVAR1 is a local variable pointing to the dialog’s text field.

If your dialog is in a Master, you should also be able to use “focused widget” as your target. i think I’ve done that before. If you can post your .rp file I would be happy to try a tailored solution for you.


#3

Hey thank you! I think the tickling idea is pretty neat. But if I read what you are saying correctly, I need to make a bunch of if conditionals to go through all the possible widgets…maybe I got that wrong. That removes the kind of ‘unspecific-ness’ that I’m hoping to achieve: I can add any number of text widgets and edit the text on them.

I did think through one kind of funny possibility: make the whole page a giant selection set. That creates an interesting automatic relationship between widgets. I’ve attached it for fun, as well as my interpretation of your solution. I didn’t tickle the widget exactly, because if I need to test for each name, I can just write the text to that widget.

Editor.rp (112.8 KB)

Now I need to figure out some way that the text pushes and pulls other widgets…dynamic panels will probably work, but seems inelegant.

Thanks again!


closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.