-
July 23rd, 2019, 21:43 #11
From the sounds of it the buttons are appearing over the top of each other all stacked as one.
Looking at the code I'd expect it to build them one under the other like a column with each button visible.
Unless there is something odd with the anchor "text" I'm not seeing... I dunno why it doesn't work.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
July 26th, 2019, 06:11 #12
Ok, still not working well. I guess I just need some basic layout help.
Given that I have a textfield named "text" that is correctly positioned in the window (it is inset from the borders and centered), what do I need to do to layout 3 buttons below the textfield that would look something like this:
Code:+---------------------------------+ ! ! ! Textfield "text" ! +---------------------------------+ +---------+ +---------+ +---------+ !Button 1 ! !Button 2 ! !Button 3 ! +---------+ +---------+ +---------+
What would I need to do If I wanted them to be stacked vertically, instead of horizontally?
Code:+---------------------------------+ ! ! ! Textfield "text" ! +---------------------------------+ +---------------------------------+ ! Button 1 ! +---------------------------------+ ! Button 2 ! +---------------------------------+ ! Button 3 ! +---------------------------------+
-
July 26th, 2019, 06:43 #13
If you want to get them side by side try something like...
buttons[i].setAnchor("top", "text", "bottom", "absolute",5);
buttons[i].setAnchor("left", "text", "right", "relative",-SomeValueBasedYoullhavetoFigureout);
"SomeValueBasedYoullhavetoFigureout" = You'll have to just figure out what the offset will need to be to actually be on the bottom left. If you try and use relative on the left/left alignment it wont do what you want.
That "should" place them under the text field left to right as your first layout is going for.
buttons[i].setAnchor("top", "text", "bottom", "relative",5);
buttons[i].setAnchor("left", "text", "left", "absolute");
That should stack them one on top of the other aligned to the left corner of the "Text" field.Last edited by celestian; July 26th, 2019 at 06:46.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
July 27th, 2019, 01:35 #14
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
When I do 3 buttons like that, I usually anchor bottom and left for the 1st button, bottom and right for the 3rd button, and bottom and center for the 2nd button.
In that way, the buttons will be positioned correctly, even if I change the window size later.
Regards,
JPG
-
July 27th, 2019, 01:40 #15
I think in the OPs use case he has a variable number of buttons so needs to anchor the first and each following one would be relative?
-
August 22nd, 2019, 03:33 #16
Since I was unable to insert my buttons into the view correctly, I did the next best thing... when the user hovers over the middle of the Notes view, a series of buttons pop up indicating the various rolls that can be made. The buttons disappear if the user moves the mouse away, or click in the Notes view to edit.
My only problem now is that I would like the buttons to be variable width, based on the text in the button field, and at the moment, I am forced to define a left and a right anchor. As you can see from this:
3.png
The last button's label "Click to roll [Sex Appeal+1]" is too large for the button.
Is there a way to define a left/right anchor that is "in the middle", and have the button grow horizontally to fit it's label?
-
August 22nd, 2019, 03:54 #17
Not sure about buttons. But for string controls, if the left anchor is defined, but the right anchor isn't, then the string field will expand to fit the text. I don't know if such an approach would work with buttons. You may need to assign a minimum width in the sizelimits parameter. Here's what I used for a stringcontrol that has a minimum width, but will resize horizontally beyond that based on the contents of the control:
Code:<anchored to="label_price" position="righthigh" offset="5,2"> <sizelimits> <minimum width="30" /> </sizelimits> </anchored>
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
August 22nd, 2019, 05:05 #18
Yeah, it doesn't seem to resize the buttons based on their text. At least not the way I am building the buttons:
Code:buttons[i] = window.createControl("notes_actions", bn); buttons[i].setText("Click to roll ["..a.orig.."]", "Rolling ["..a.orig.."]!"); buttons[i].setFrame("buttonup"); buttons[i].setVisible(false); buttons[i].setAnchor("left", parent, "left", "absolute", q1x); buttons[i].setAnchor("top", parent, "top", "absolute", top); buttons[i].setAnchor("bottom", parent, "top", "absolute", top + buttonH);
Code:<template name="notes_actions"> <buttoncontrol> <anchored to="text" position="insideleft" > <sizelimits> <minimum width="30" /> </sizelimits> </anchored> <script> function onButtonPress() window.text.buttonPressed(self); end function onClickDown() setFrame("buttondown"); end function onClickRelease() setFrame("buttonup"); end </script> </buttoncontrol> </template>
Last edited by Nose66; August 22nd, 2019 at 05:08.
-
August 22nd, 2019, 17:52 #19
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
You need to return true for all of those event functions to indicate to the client code that you want to capture those events, and not use the default processing. Also, you might consider only using the onButtonPress event; and setting the frames using "state" tags. You can also set tags in the template to mirror starting state (i.e. "invisible" tag, instead of calling setVisible(false)).
https://www.fantasygrounds.com/refdoc/buttoncontrol.xcp
For layout, if left or right anchor is defined and the other horizontal anchor is not defined and the width is not defined, then the control should resize to fit the text inside (plus any frame offset).
Regards,
JPG
-
August 22nd, 2019, 19:33 #20
That sounds promising... how do you do that? Looking at the setStateFrame API it reads:
A string identifying the state for which the frame is to be set. This value should be one of "hover", "drophilight", "drophover", or "keyedit".
I was looking for was a way to show the button as being pressed down, and then pop back up. Unfortunately, onButtonPress won't allow me to show when the button is pressed down, since it only fires when the button is released.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks