Using OnClick in menu options

Posts from previous Beta sessions

Using OnClick in menu options

Postby Vlorn » Mon Oct 29, 2007 2:28 pm

Trying to use the "Onclick" parameter in a radio box in the config menu, but the initARC function designed to clean up option boxes seems to interfere with the "OnClick" parameter. Is there anyway to use "OnClick" while still using the initARC function to clean the formatting?

I'm trying to create warning popups when specific menu options are selected, before the form is submitted.

-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Using OnClick in menu options

Postby PleegWat » Mon Oct 29, 2007 3:40 pm

The initARC creates the skinned check/radio boxes. I think it uses the onclick to change the texture.
I think it only affects radio buttons that meet a certain condition. But that condition may be 1, or the name starting with config_, in which cases you're screwed.

Zanix, any ideas? You put it in.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Using OnClick in menu options

Postby PleegWat » Mon Oct 29, 2007 3:46 pm

EDIT: Yeah, it affects all radio/check boxes in the config form and it overwrites the onclick. I might (with emphasis on might) check one of these days if I can fix this up.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Using OnClick in menu options

Postby zanix » Mon Oct 29, 2007 11:57 pm

It overwrites all radio and check boxes
We will make a post on the author's site to see if he can working in a fix
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Using OnClick in menu options

Postby Vlorn » Sat Nov 03, 2007 1:00 pm

So I e-mailed the author of ARC directly (he responded the same day) and he provided the following info on modding his widget to support onClick functionality.

Sorry I haven't replied. I don't monitor that thread much any more.

The answer, is yes. It would be a very small modification.

Off the top of my head it would be something like the following;

/*-- pseudo javascript --*/
var originalOnclick = label.onclick;
label.onclick = function(){
/* do whatever the onclick was being replaced with here */
/* and call the original click function */
originalClick();
}

If I was to do this all again, now being older and wiser, I'd be attaching events using something like prototype's addEventListener, rather than on the onclick directly.

Hope that helps. I'll consider rewriting this using as a prototype class again shortly.



So I modified mainjs.js around line 342 from this;
Code: Select all
         //when the label is clicked, call toggleLabelStyle and toggle the label
inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassRadio, offClassRadio);
       return false;
       };


To This;

Code: Select all
         //when the label is clicked, call toggleLabelStyle and toggle the label
         
       if(inputs[i].label.onclick){
   var originalOnclick = inputs[i].label.onclick;
      inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassRadio, offClassRadio);
      originalOnclick();
      return false;
       };
       }else{
       inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassRadio, offClassRadio);
       return false;
       };
       }


I did some basic testing and didn't find any issues with it, it works without producing errors if the onclick function is set or ignored. Could a developer take a look at the code and consider adding it to the main code.

It should probably be repeated for checkboxes as well, currently the code above only modifys radio buttons.


-Vlorn

-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Using OnClick in menu options

Postby zanix » Sat Nov 03, 2007 10:24 pm

Cool, you got a response faster than I did
I didn't consider emailing him

Send an email back thanking him for his help :)

There is a second instance where toggleLabelStyle() is called just 10 lines lower

Replace
Code: Select all
inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassCheckbox, offClassCheckbox); return false; };


With
Code: Select all
if(inputs[i].label.onclick){
   var originalOnclick = inputs[i].label.onclick;
   inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassCheckbox, offClassCheckbox); originalOnclick(); return false; };
}else{
   inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassCheckbox, offClassCheckbox); return false; };
}
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Using OnClick in menu options

Postby Vlorn » Sun Nov 04, 2007 11:35 am

So now the fun part, how can I add an "onClick" event to a standard config menu option?

I'm working on an addon, that can be really destructive to a database if the options aren't handled properly (the mod will modify the users Nuke Database).

I'd really like the ability to have popup warnings on a few of the menu options to ensure the user is aware that some options will modify the nuke DB.

I can easily add it to my custom DB, but I also need to add it the basic addon config options if possible.

-Vlorn
User avatar
Vlorn
WR.net Apprentice
WR.net Apprentice
 
Posts: 29
Joined: Tue Jul 04, 2006 7:57 pm

Using OnClick in menu options

Postby zanix » Sun Nov 04, 2007 11:40 am

LoL
You are correct, there is no way to add anything like this to a field

I think an extra parameter entry could be made
Code: Select all
radio{on^1|off^0{extraparams
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US


Return to Archived

Who is online

Users browsing this forum: No registered users and 1 guest

cron