Create a macro with list of items to chose from

Hello,
I created a macro to format text in a colored box, and would like to have the colour option as a dropdown list to select between specific choices.
Right now my macro works but I have to manually enter the “colour=Red” or “colour=Blue” in the wiki source editor, I would like a dropdown list in wysiwyg editor when I insert my macro.

I created my WikiMacroClass and WikiMacroParameterClass but can’t find how to make the list of predefined choices for my WikiMacroParameterClass
The documentation (https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/WikiMacroTutorial/) is laking informations unfortunatly

Also, because I’m trying to reuse existing macros to learn how to, I have this message on existing and working macros :

image

But I don’t have this message on my macro I write myself, what does this means ?

Thanks

The doc links to https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/Using%20custom%20pickers%20for%20XWiki%20Rendering%20Macro%20parameters/ (from https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/WikiMacroTutorial/#HParameters).

Just tested using the java.awt.Color parameter type and it works fine :slight_smile:

Screenshot 2024-02-20 at 13.28.53

This just means that an XObject is using some xproperties that don’t exist anymore. It’s not a problem.

Hello,
Thanks I found by luck this java color picker, but it does not answer my problem.
I want a drop down list of pre defined choices.

Is that possible ?

Thanks

Then it’d be a custom picker that is needed and you’ll need to implement it. Unless you don’t want a color picker at all but just a list of text elements. Then you could implement an Enum as is indicated on the page:

You can also provide the reference of an existing Java Enum to get a custom select picker with its values. If you want to create a custom enum for your parameter, you can try the following approach.

See https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/Using%20custom%20pickers%20for%20XWiki%20Rendering%20Macro%20parameters/

Ok thanks, too much complicated to create a dropdown select list, I’m not familiar with java so building a .jar to import it seems too much effort, users will have to write from the list I provide them in the parameter description.