PDA

View Full Version : Problem with Tooltips on a buttoncotntrol



Bidmaron
July 21st, 2018, 17:05
I think I have some kind of a conceptual error regarding button controls. I always struggle to get tooltips to work properly. My current dilemma:
I have an Export button that is modal (you press it so you can export one or more tables and press it again when you are done exporting). The button permits you to either enter an export mode where you can select tables or generators in the list and export them one-at-a-time, or, if you push the Alt key when you click the export button, you can mark tables for exporting into one file with multiple tables. Then when you click the export button again, all the marked tables get exported.
So, the tooltip needs to have one of three values:

When the button is not pressed:

"gen_export_button_up" = Depress to export tables or generators one at a time (<alt> to mark multiple items for export)

When the button has been pressed w/o the Alt key:

"gen_export_button_down"=Click to exit export mode

When the button has been depressed with the Alt key:

"alt_gen_export_button_down"=Click to export marked items


Here is the export button declaration:

<template name="button_export">
<buttoncontrol>
<anchored to="buttonanchor" width="50" height="20">
<top />
<left anchor="right" relation="relative" offset="5" />
</anchored>
<pressed name="buttondown" offset="2,2,2,2" nobaseframe="true" />
<font>button-white</font>
<textres>gen_export</textres>
<state tooltipres="gen_export_button_up" frame="buttonup" frameoffset="2,2,2,2"/>
<state tooltipres="gen_export_button_down" frame="buttondown" frameoffset="2,2,2,2"/>
<script file="export_table_generator.lua" />
</buttoncontrol>
</template>


Here is the code that sets the tooltip based upon the button state and the status of the Alt key (and this code is invoked when the button is depressed, in addition to when hovering):

function onHover(state)
--if state then
if getValue()==0 then
setTooltipText(Interface.getString("gen_export_button_up"));
elseif bAlternate then
setTooltipText(Interface.getString("alt_gen_export_button_down"));
else
if getTooltipText()~=Interface.getString("gen_export_button_down") then
Debug.chat("setting tooltip text");
end
setTooltipText(Interface.getString("gen_export_button_down"));
end
--end
end

Note that, in the code above, bAlternate is a variable in the script block that is set according to the alt key status when the button is depressed.
So, when you hover on the button before pushing it, the screen has the appearance of the first screen shot below, but when you hover over it once it is pressed, there is never a tooltip displayed, regardless of the alternate key status when the button was pushed, as you can see from the second screenshot. When you push export again to return to normal mode, the original tooltip for button up will be displayed.
24034
We know that the onHover code is working, because the debug shows up in the chat window.
(Note that the control that appeared to the right of the export button is where any module dependency would appear, and note that the export icons on each line get added when Export is clicked)

Bidmaron
July 21st, 2018, 22:27
Another issue:
I need a control that will only accept a string drop but cannot be user edited. I have it working, but the user can go in and type into the field. I tried specifying <disable/> but that wouldn't let you drop on the field. I don't think <readonly/> lets you drop either, but I guess I can test that. I just don't see a flag in windowcontrol, textbasecontrol, or string control that will disable user editing but still permit dropping.
Edit: <readonly /> doesn't even have a highlight frame when you try to drag to it, and it sure won't let drop happen.

damned
July 22nd, 2018, 01:04
Doesnt really answer your Q but when I have buttons that have different click/button+click/scroll options on the same button I have always listed them all in the one tooltip.

Bidmaron
July 22nd, 2018, 06:15
Thanks, damned, but I am too stubborn to give up on it, and I am ready to conclude that there is a bug with tooltips and multi-state buttons.

Any idea on the second post?

damned
July 22nd, 2018, 06:26
Who would do the drag and drop?
if its only the GM then there is a <gmonly /> or similar tag that might practically solve the issue without doing it fully?

Bidmaron
July 22nd, 2018, 16:09
It would be the GM. I have a work-around now, but maybe MW will chime in and tell me how you are really supposed to do this. The system is so flexible I have a hard time believing you can't do this.

My workaround: capture onChar events and keep changing the value back to what it previously was, sending an error message to the chat window. Works, but a little bit of a kluge.

celestian
July 22nd, 2018, 16:14
It would be the GM. I have a work-around now, but maybe MW will chime in and tell me how you are really supposed to do this. The system is so flexible I have a hard time believing you can't do this.

My workaround: capture onChar events and keep changing the value back to what it previously was, sending an error message to the chat window. Works, but a little bit of a kluge.

<gmeditonly /> is what you're looking for to keep a value from being edited by anyone but the host.

Bidmaron
July 22nd, 2018, 16:48
That is not what I want, celestian. I need it to where you can only drag to it, not manually edit. I have tried all the combinations of tags I can find. I don't think it can be done, but, as I said, I have a workaround.

celestian
July 22nd, 2018, 19:21
That is not what I want, celestian. I need it to where you can only drag to it, not manually edit. I have tried all the combinations of tags I can find. I don't think it can be done, but, as I said, I have a workaround.

Sorry, I thought you wanted the DM to be the only one able to edit. Not that you wanted the players to be able to drag/drop and not edit.

Setting it to GMeditonly (for the manual part) and then capture drag/drop should be doable tho? Have you tested for onDrop() from a player on a GMeditonly field? Does it not even trigger? (never had a need to try this myself). Tho based on your readonly problem my guess is it doesn't.

Bidmaron
July 22nd, 2018, 20:48
What I need is a string that can only be dragged to not edited. This is because you are dragging a library icon dependency which my ondragstart code for the library makes a string out of the module name.

As I said, I have a workaround so not that big of a deal.

The tooltip problem, on the other hand, is irritating and I think just a bug with button controls.

Moon Wizard
July 25th, 2018, 00:45
I'm not clear how to recreate this bug in a simple manner, and I don't have enough time to unwind your work. Can you provide a simple extension that has the issue without all the extra code?

You can also use the tooltipres="" attribute for each state to provide a custom tooltip on a per state basis for the buttoncontrol.

Regards,
JPG

Bidmaron
July 25th, 2018, 00:55
OK. The problem is that it isn't static because the depressed tooltip needs to change based on whether the <alt> key was down when you pressed the button down. Let me see if I can cram something together as a simple extension....

Bidmaron
July 25th, 2018, 01:48
Moon Wizard, I have simplified it to the bare bones in the attached extension named 'Bogus'.

To duplicate the problem, select the Tables button on the right. Hover over the export button that is in the Tables window and you will see the desired button-up tooltip. Now push the Export button, and it will switch to the depressed state. Regardless of whether you held down the <alt> key or not when you pushed the button, the down button state will have no tooltip, although it is set in the onHover code.

damned
July 25th, 2018, 04:20
Serious question - why do you want a tooltip in the down state? you have already pushed the button so what is the purpose of displaying a message? and mostly on a buton your click rather than hold the button down so a tooltip would not even get shown in many cases?

Bidmaron
July 25th, 2018, 04:25
damned, when you push the export button, you have to tell FG what to export, so you enter an export mode, and each row in the tables list has a little export button. If you hold down the alt key you can mark multiple tables to build an export package of multiple tables. The little blue buttons go to the down state so you can see which tables will export, and when you click the export button again (which is in the down state), all the marked tables get exported. If you don't hold down alt, when you click a table export button, you immediately get the dialog for the export file name, and you click the export button when you are done exporting individual tables.
I am just trying to make things as user-friendly as possible to cut down on the frequent complaints about the FG interface. Tooltips is an easy way to do that. If MW tells me he can't get to it right now, it won't break my heart. I'll just fix it later when he gets around to it. No big deal.