XWidgetSoft Forum
https://www.bbs.xwidget.com/

Save preset in config.ini
https://www.bbs.xwidget.com/viewtopic.php?f=7&t=6820
Page 1 of 1

Author:  Rom [ November 25th, 2017, 3:28 am ]
Post subject:  Save preset in config.ini

Hello

I have a concern I created a widget with several background that the user can define but I can not save each time I restart xwidget it puts me the bottom by default ........

Someone know how?
I tried various codes without success

thank you ;)

Author:  Jimking [ November 25th, 2017, 8:28 am ]
Post subject:  Re: Save preset in config.ini

Use the script in the widget that I attached you in your previous post
viewtopic.php?f=7&t=6819

Author:  Rom [ November 26th, 2017, 2:39 am ]
Post subject:  Re: Save preset in config.ini

Hi thanks

I can not make it work here is the code that I have written

Code:
function widgetOnLoad()
{
    GlassEffect.Visible = getValue('GlassEffect.visible',GlassEffect.Visible);

    GlassEffectBtn1.checked = GlassEffect.visible;
}
function GlassEffectBtn1OnClick(Sender)
{
   GlassEffect.visible = true;
   Setvalue("GlassEffect.visible","GlassEffect.Visible")
   saveIni;
   GlassEffectBtn1.checked = GlassEffect.visible;

}


Thx :)

Author:  Jimking [ November 26th, 2017, 3:18 am ]
Post subject:  Re: Save preset in config.ini

could you please attach the .xwp to check from the "inside"..?

Author:  Rom [ November 26th, 2017, 4:10 am ]
Post subject:  Re: Save preset in config.ini

i send you the widget
https://www.mediafire.com/file/5l56qtdy ... t_Beta.zip

thx

Author:  Jimking [ November 26th, 2017, 5:31 am ]
Post subject:  Re: Save preset in config.ini

It's a bit complicated widget since there are a lot of layers and submenus and I don't know how will work..
So I'll give you a general script that works for 2 or more layers or images that you want to make tem selectable (show/hide) through the right click option or with clickon function.
Just replace the layer1, layer2, function menu..... with the names of the layers or images or whatever you want to use.

Code:
function menuitem1OnClick(Sender)
{
  layer1.visible = true;
  layer2.visible = false;
  setValue('layer1.visible',layer1.Visible);
  setValue('layer2.visible',layer2.Visible);
  saveIni;
  menuitem1.checked = layer1.visible;
  menuitem2.checked = layer2.visible;
}

function menuitem2OnClick(Sender)
{
  layer1.visible = false;
  layer2.visible = true;
  setValue('layer1.visible',layer1.Visible);
  setValue('layer2.visible',layer2.Visible);
  saveIni;
  menuitem1.checked = layer1.visible;
  menuitem2.checked = layer2.visible;
}


function widgetOnLoad()
{
  layer1.Visible = getValue('layer1.visible',layer1.Visible);
  layer2.Visible = getValue('layer2.visible',layer2.Visible);

  menuitem1.checked = layer1.Visible;
  menuitem2.checked = layer2.Visible;
}


If you want to show/hide a single layer,image etc use this one:

Code:
function menuitem1OnClick(Sender)
{
  widget.cmd("!ShowHideObj=layer1");
  setValue('layer1.visible',layer1.Visible);
  saveIni;
  menuitem1.checked = layer1.Visible;
}


function widgetOnLoad()
{
  layer1.Visible = getValue('layer1.visible',layer1.Visible);
  menuitem1.checked = layer1.Visible;
}

Author:  Rom [ November 26th, 2017, 5:45 am ]
Post subject:  Re: Save preset in config.ini

i will try this now :)
And yes it's a beta widget..its have lots of layer i create a new version with less layer as possible to make it easier ;)

Author:  Rom [ November 26th, 2017, 6:30 am ]
Post subject:  Re: Save preset in config.ini

Thank you very much it works finally :)

In revenche I have a slight bug easy to solve I think, to activate my layer I use a checkbox except that if I disable the layer via this checkbox it remains tick .... that the effect be activated or not. ... here is a screen for you to see and the code that goes with it;)

Glass Active
https://gyazo.com/af169b064bafbd48d384ab710d0175ab
Glass not active but checkbox are checked
https://gyazo.com/351fdb51b52b3ac0d5047440c11a9641

And you'r code
Code:
function widgetOnLoad()
{
  EffectGlass.Visible = getValue('EffectGlass.visible',EffectGlass.Visible);
  GlassCheckBox.checked = EffectGlass.Visible;
  SaveIni()
}

function GlassCheckBoxOnClick(Sender)
{
  widget.cmd = "!FadeInOutVisibleObj=EffectGlass"
  setValue('EffectGlass.visible',EffectGlass.Visible);
  SaveIni()
  GlassCheckBox.checked = EffectGlass.visible;
}


i will try to find a way for this bug but i'm a novice in scripting :)

Thank for you'r help :)

Author:  Jimking [ November 26th, 2017, 2:52 pm ]
Post subject:  Re: Save preset in config.ini

This is not a bug Rom.
When the layer is visible, the checkbox will be activated. So the script overwrites any manual "uncheck" option.
You need to "play" with the "visible"option and keep the layer "invisible" on the start.
If you have it visible you will have the opposite result..

Author:  Rom [ November 27th, 2017, 7:40 am ]
Post subject:  Re: Save preset in config.ini

Ok ok but i set my layer invisible by default
https://gyazo.com/0fab4555a236dba378c9e4ec2bba7ff2

if i understand I have to change this in my code
Code:
widget.cmd = "!FadeInOutVisibleObj=EffectGlass"

by this
Code:
layer1.visible = true;


Edit : XW have uncheck function for check button ?

Author:  Jimking [ November 27th, 2017, 8:48 am ]
Post subject:  Re: Save preset in config.ini

With the first code you can show hide the component
With the second the layer will stay visible.
Depends on what you want to do

Author:  Rom [ November 28th, 2017, 6:07 am ]
Post subject:  Re: Save preset in config.ini

ok realy thanks for you'r help
i have learn loot of good things :)

I have a question, can i call a external javascript file created by me ?
i find codes on internet but does't work....

thanks :)

Author:  Jimking [ November 28th, 2017, 9:47 am ]
Post subject:  Re: Save preset in config.ini

You're free to use any java script you want. Personally I shave no problem with it.
You can find external java scripts but you need to know how to edit them and make them work properly to your design. And it's not so easy especially for novice users.
There are so many ready widgets for XWidget and you can find many many functions.
That's way I did :)

Author:  Rom [ November 28th, 2017, 1:10 pm ]
Post subject:  Re: Save preset in config.ini

Yes I search a lot too and I find a lot of useful things.
Is it possible to put the windgetOnLoad function in a .js file rather than in the widget itself?

sorry with all that is question but I'm embarking on a pretty big project and I just miss some info :)

thank you

Author:  Jimking [ November 28th, 2017, 4:54 pm ]
Post subject:  Re: Save preset in config.ini

Rom wrote:
Yes I search a lot too and I find a lot of useful things.
Is it possible to put the windgetOnLoad function in a .js file rather than in the widget itself?

I don't understand what do you mean with it..

Author:  Rom [ November 29th, 2017, 6:54 am ]
Post subject:  Re: Save preset in config.ini

I would like to put the WidgetOnLoad function in a .js file because I am created a widget with a lot of options and customization and suddenly so that my code be readable easily I had the question of knowing if I could put all the backup function in an external file and the loaded at launching the widget

Author:  Jimking [ November 29th, 2017, 2:44 pm ]
Post subject:  Re: Save preset in config.ini

You can create a second clone widget with a different name if you want to backup your design/java script.
The java script in general like the WidgetOnLoad works for the widget itself. There is no way to interact with more widgets using a java script.
I hope that I replied to your question, because really I don't understand well your thought. The Google translator is bad... :)

Author:  Rom [ November 30th, 2017, 3:23 am ]
Post subject:  Re: Save preset in config.ini

Yeah google translation is realy bad :)

I show you my only WidgetOnLoad function.
Code:
function widgetOnLoad()
{
// -------------------- Background Color Panel ------------------ //
// -------------------- Black Background btn -------------------- // 
  BgColorBlack.Visible = getValue('BgColorBlack.visible',BgColorBlack.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  black01.checked = BgColorBlack.Visible;
  black01.checked = ImagesLayer.Visible;
  black01.checked = Colors.visible;
// -------------------- Blue01 Background btn -------------------- //
  BgColorBlue01.Visible = getValue('BgColorBlue01.visible',BgColorBlue01.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  blue01.checked = BgColorBlue01.Visible;
  blue01.checked = ImagesLayer.Visible;
  blue01.checked = Colors.visible;
 
  BgColorBlack.visible = getValue('BgColorBlack.visible',BgColorBlack.visible);
  blue01.checked = BgColorBlack.visible;
// -------------------- Blue02 Background btn -------------------- //
  BgColorBlue02.Visible = getValue('BgColorBlue02.visible',BgColorBlue02.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  blue02.checked = BgColorBlue02.Visible;
  blue02.checked = ImagesLayer.Visible;
  blue02.checked = Colors.visible;
 
  BgColorBlack.visible = getValue('BgColorBlack.visible',BgColorBlack.visible);
  BgColorBlue01.visible = getValue('BgColorBlue01.visible',BgColorBlue01.visible);
  blue02.checked = BgColorBlack.visible;
  blue02.checked = BgColorBlue01.visible;
// -------------------- Blue03 Background btn -------------------- //
  BgColorBlue03.Visible = getValue('BgColorBlue03.visible',BgColorBlue03.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  blue03.checked = BgColorBlue03.Visible;
  blue03.checked = ImagesLayer.Visible;
  blue03.checked = Colors.visible;
 
  BgColorBlack.visible = getValue('BgColorBlack.visible',BgColorBlack.visible);
  BgColorBlue01.visible = getValue('BgColorBlue01.visible',BgColorBlue01.visible);
  BgColorBlue02.visible = getValue('BgColorBlue02.visible',BgColorBlue02.visible);
  blue03.checked = BgColorBlack.visible;
  blue03.checked = BgColorBlue01.visible;
  blue03.checked = BgColorBlue02.visible;
  // -------------------- Blue04 Background btn -------------------- //
  BgColorBlue04.Visible = getValue('BgColorBlue04.visible',BgColorBlue04.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  blue04.checked = BgColorBlue04.Visible;
  blue04.checked = ImagesLayer.Visible;
  blue04.checked = Colors.visible;
 
  BgColorBlack.visible = getValue('BgColorBlack.visible',BgColorBlack.visible);
  BgColorBlue01.visible = getValue('BgColorBlue01.visible',BgColorBlue01.visible);
  BgColorBlue02.visible = getValue('BgColorBlue02.visible',BgColorBlue02.visible);
  BgColorBlue03.visible = getValue('BgColorBlue03.visible',BgColorBlue03.visible);
  blue04.checked = BgColorBlack.visible;
  blue04.checked = BgColorBlue01.visible;
  blue04.checked = BgColorBlue02.visible;
  blue04.checked = BgColorBlue03.visible;
  // -------------------- Blue05 Background btn -------------------- //
  BgColorBlue05.Visible = getValue('BgColorBlue05.visible',BgColorBlue05.Visible);
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.visible = getValue('Colors.visible',Colors.visible);
  blue05.checked = BgColorBlue05.Visible;
  blue05.checked = ImagesLayer.Visible;
  blue05.checked = Colors.visible;
// -------------------- Background Images Panel ------------------ //
  ImagesLayer.Visible = getValue('ImagesLayer.visible',ImagesLayer.Visible);
  Colors.Visible = getValue('Colors.visible',Colors.Visible);

  AkBg.checked = ImagesLayer.Visible;
  AkBg.checked = Colors.Visible;
 
// -------------------- Background Tranparence ------------------ //
  Trans00.Opacity = 1;
  Trans10.Opacity = 1;
  Trans20.Opacity = 1;
  Trans30.Opacity = 1;
  Trans40.Opacity = 1;
  Trans50.Opacity = 1;
  Trans60.Opacity = 1;
  Trans70.Opacity = 1;
  Trans80.Opacity = 1;
  Trans90.Opacity = 1;
 
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
  WidgetBackground.Opacity = getValue('WidgetBackground.Opacity',WidgetBackground.Opacity);
 
  Trans00.checked = WidgetBackground.Opacity;
  Trans10.checked = WidgetBackground.Opacity;
  Trans20.checked = WidgetBackground.Opacity;
  Trans30.checked = WidgetBackground.Opacity;
  Trans40.checked = WidgetBackground.Opacity;
  Trans50.checked = WidgetBackground.Opacity;
  Trans60.checked = WidgetBackground.Opacity;
  Trans70.checked = WidgetBackground.Opacity;
  Trans80.checked = WidgetBackground.Opacity;
  Trans90.checked = WidgetBackground.Opacity;


// -------------------- Widget Effect Glass --------------------- //

  EffectGlass.Visible = getValue('EffectGlass.visible',EffectGlass.Visible);
  GlassON.Visible = getValue('GlassON.Visible',GlassON.visible);
  GlassOFF.Visible = getValue('GlassOFF.Visible',GlassOFF.Visible);
 
  GlassOFF.visible =getValue('GlassOFF.visible',GlassOFF.visible);
  GlassON.visible = getValue('GlassON.visible',GlassON.visible);
  EffectGlass.visible = getValue('EffectGlass.visible',EffectGlass.visible);
 
  GlassCheckBox.checked = EffectGlass.Visible;
  GlassCheckBox.checked = GlassON.visible;
  GlassCheckBox.checked = GlassOFF.visible;
 
  GlassCheckBoxOff.checked = GlassOFF.visible;
  GlassCheckBoxOff.checked = GlassON.visible;
  GlassCheckBoxOff.checked = EffectGlass.visible;
  SaveIni()

// -------------------- WidgetOnLoad Settings FIN --------------- //



I would like to know if i can put this code on a external javascript file
and call this file when launching the widget ?

I hope I have been a little clearer and understandable :)

Author:  Jimking [ November 30th, 2017, 1:29 pm ]
Post subject:  Re: Save preset in config.ini

As I said no it's not possible. The WidgetOnLoad function works only through the widget itself and should be placed in the Designer and XWidget will load all the data from there only. No external commands work with Xwidget widgets.

Author:  Rom [ December 12th, 2017, 8:03 am ]
Post subject:  Re: Save preset in config.ini

hey..i up this post :)
I have a question, what are the attributes for the following effects?
Inner Shadow and Shadow ?
I will try this but no succes....
Code:
layer1.Background.Effect.Shadow.Enabled = false;
layer1.Background.Effect.InnerShadow = false;


thanks :)

Author:  Jimking [ December 12th, 2017, 11:32 am ]
Post subject:  Re: Save preset in config.ini

I don't know the js format for this.. Sorry
But why not try to create two "layers" with corrisponding effects on/off and use the same show/hide mentality like the cases above..?
Option to show layer1 with effects - hide layer2 without effects and the opposite

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/