Onset varible
I have an option in my collections window that when you hit the add button it adds the collectible to the collection (normal) and than auto closes the window.
Now instead of having this on the add button all the time, i wish to add a checkbox at the bottom of the window that sets this variable. OnSet=Parent.Parent.CollectionTemplate.AddButton.OnPress='hide_window Journals.JournalsQuest' UnSet=Parent.Parent.CollectionTemplate.AddButton.OnPress='' (blank so it removes the behavior) This is all done thru the default window so the hierarchy and such is normal other than the on added checkbox i added at the bottom, which is at the same location as the other 2 checkboxes. Now my issues is the checkbox doesnt change the OnPress varible when in-game. What am I doing wrong here? Thanks, Draven |
I've found that modifying default buttons within the UI is a bad idea. Sometimes it'll work, and sometimes it won't. Other times you'll get unexpected results.
I like to think that these buttons already have "OnPress" events and adding another is sometimes a bad idea. What I do is clone whatever "default UI" button it is I'm working with and call it another name and place it ontop of that button. I put my code I need to use in that button and make the final step of the code to trigger the "default" button. In this case it would be the add button. With the code you're trying to do, I suggest just making 2 different buttons that get toggled visibly over the button. One button would trigger the Add button and auto close, the other would just trigger the Add button. You're check box could control which one is showing. Cheers. |
I was thinking of that also but two problems come to mind
I am working on a diffrent part of the UI right now, i'll try the 2 button idea in a minute or so and report back sir. Thanks, Draven |
I changed the name of the button and it doesn't work now. First off its always visible and when you press the button the collectible item isn't added to the collection.
Draven |
OK re-reading your reply i think i miss understood you.
{AutoClose} <-- Add the auto close visible code to effect this one? Make the checkbox effect this buttons visible? How do I make this button "fire" the default button? {Default add} I hope i understood it ok this time around, sorry :( Thanks, Draven |
It isn't working for two reasons. One is what Drumstix said, the other is that you are only modifying the template row, not the actual row. So make sure that you create that custom button within the template. Also your checkbox will not affect anything, have your code within the new button check the state of the checkbox instead.
|
OK i think you both have went right over my poor head, sadly.
Maybe oyu can post some sample code so I can follow you a bit better? Draven |
<SNIP>
Coding not smart when tired. lol. Silat |
lol @TalTal
|
Don't actually modify the normal Add button. I wanted you to "clone" it IE make one that mimics it and that's where your extra code goes. This code then triggers the Add button
[Check box] toggles which button # is visible {YourCloned button #1} Press it, do some stuff, press the Add button, close window {YourCloned button #2} Press it, do some stuff, press the Add button {Add button} gets pressed by the cloned button |
Quote:
how to make my button press the default button? I know how to make it visible or not and how to close the window. Thanks both of you for bareing with me on this :) Draven |
Reference it correctly and do a AddButton.press=true
... or whatever it's called in the XML |
Yeah, the press=true was my mistake, but i am having the issue of with the checkbox the buttons aren't changing visibility in-game, in the uibuilder they are.
|
Quote:
|
Quote:
|
What he is saying is...
Read the state of your checkbox (checkbox.checked) via your fake add button. You can't insert data into the correct row where the add button resides b/c the game copies the template XML (the row XML code) and adds rows as needed at runtime(when the window is created in _HUD) from the copied template XML. Thus your check box is only changing the data in the template row not the real row that your add button is really in. It does this before the window is shown so using the OnShow of the main window is useless in this case. |
Quote:
Like where ot put the code in my "custom button"? How to check the state of my check box from my "custom button"? |
I wasn't even thinking of which Add button this was until now. So yeah, as they already said, you can't reference the Add button or the cloned buttons from the Checkbox.
So, leave your checkbox as is, and don't put any special code in it. What you'd probably have to do, is use a OnHoverIn code to show your fake Add button or not. The code would look something like this: OnHoverIn="Visible=(Parent.Parent.YourCheckBox.checked == true)" That way if the checkbox wasn't checked, the fake button would hide, and the normal Add button would then be pressable. You'd have to put this "OnHoverIn" code directly on the FakeAdd button I'm thinkin though, so it would get copied through the whole template. |
Quote:
My button has HoverIn=Visible=(Parent.Parent.FilterPage.AutoClose.checked == true) But the issue now is if the checkbox (Named AutoClose) keeps the button visible if the check box is checked as needed, and if i uncheck the box it disappears on mouse-over, but if i re-check the box and mouse-over the button again the custom button doesn't re-appear. The funny thing about this code is its not even for me, its for a friend that wanted this option added to her UI lol. |
Ah, right, once it hides itself, it wouldn't be able to trigger an OnHover again since OnHover only works for visible things. You're best bet is to use a page that sits on top of the button, and always visible, but has nothing in it AbsorbsInput=false and has no style. That page can have the OnHoverIn code to tell the fake button to appear or not. That way it always gets triggered.
Sorry for the scatterbrain-ness. |
OnHoverIn is messy. The usual way is to create two custom buttons, one to overlay the default button, the second one is invisible. Invisible one gets your hide_window code in it's OnActivate event, followed by an activated=false. The first button activated the second button depending on the state of the checkbox, so Parent.SecondButton.Activated=Parent.Parent.YourCheckbox.checked.
|
Yeah, that works too.
|
1 Attachment(s)
Thanks for all the help everyone, but I couldn't get either Drumstix's or GM9's options to work, but in the good news i figured out a way other than those ways ...
I added 2 buttons to the template file both "new" buttons press the default add button, one of the custom buttons also /hide_window also. The reason I added the 2nd custom button instead of using the default add button was because my custom "add and close" button was always visible and the default "add" button wasn't. SO I added a 2nd custom button so it was always visible like my first custom button but behaves like the default add button. The words overflow a bit on the first button for right now because this is just a temporary fix until i recode / re-skin this window in the future. Thanks again for all the help, i just couldn't get it to work. Draven |
All times are GMT -5. The time now is 10:11 PM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI