[Gambas-user] Custom controls, Non-String arrays in the IDE
Bruce Steers
bsteers4 at gmail.com
Wed Aug 17 22:39:40 CEST 2022
On Wed, 17 Aug 2022 at 16:45, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>
> On Wed, 17 Aug 2022 at 13:19, Benoit Minisini <
> benoit.minisini at gambas-basic.org> wrote:
>
>> Le 17/08/2022 à 13:42, Bruce Steers a écrit :
>> >
>> > Let's put the usefullness of flashy gradient buttons aside.
>> > What you
>> > would need is actually a brush, not a gradient. The gradient
>> > is just a
>> > particular case of a brush.
>> >
>> > And editing a brush (or any other complex property) in the
>> > form editor
>> > needs:
>> >
>> >
>> > oh my god you're right. and right about the ReportBrush too.
>> > Sorry i didn't get it at first.
>> >
>> > I can just use a string value set to use {ReportBrush} type and there
>> is
>> > everything i needed in a string that I can easily work with. don't even
>> > need to add gb.report.
>> >
>> > Awesome :)
>> > Respects.
>> > BruceS
>> >
>>
>> It's not enough. The problem is that you must understand how property
>> values are stored in and retrieved from form files.
>>
>> "ReportBrush" is not just the way the property is chosen in the form
>> editor, it's also which code is generated in the form file to initialize
>> the property. You can't reuse it directly.
>>
>> For complex objects like brushes, you usually need an equivalent object
>> in the component. For example, properties with "ReportBrush" kind uses
>> the 'ReportBrush[]' array method of the gb.report(2) component.
>>
>> That logic is located in the 'CControl.GetEachProperty()' method.
>>
>> Regards,
>>
>
> Yes i spoke too soon in my excitement of your suggestions finally hitting
> me and thinking i had a really simple solution.
> It was all working editing in the IDE so I thought everything was great,
> but then i got an error when running the program (no ReportBrush)
>
> So i have imported the ReportBrush.class and now it works like you say,
> not as a string but as an actual reportbrush object. Still that's
> something i can use.
>
> Shame i cannot disable the color/image options of the reportbrush editor
> but i'll work around it :)
>
So i did this to get a gradient only dialog...
https://gitlab.com/bsteers4/gambas/-/commit/07546d3bbf2a57cf3ba793573a43dc4501407649
I just added an option GradientOnly to the ReportBrush type so you can use
MyGradient{ReportBrush:GradientOnly} and it hides the color/image options
it removes the first 2 color/image items from the list and offsets all the
combo.index calls by 2 if removed.
have tested it and tested it alongside another brush property that used all
4 types and no problems using both.
Could you accept something like this?
Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220817/0ef18e43/attachment-0001.htm>
More information about the User
mailing list