Aller au contenu

Photo

OnToolTip UI events


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
MasterChanger

MasterChanger
  • Members
  • 686 messages
I've been having some strange trouble with OnToolTip events in specific cases as part of a GUI project I'm working on. Functions seem to fire just fine from OnToolTip events if the element they are part of is a standalone element. However, if the element is created from a prototype in a ListBox element, the OnToolTip event does not work.

I've tried other events, like OnLeftClick and OnRightClick, for ListBox prototype elements (such as UIButton or UIPane) and they work fine. I can successfully call UIObject_Tooltip_DisplayTooltipString from an OnLeftClick event if I want to (not that I want to).

I have also tested calling various other functions from OnToolTip events of prototype elements, such as ExecuteServerScript, but have not had any success.

On the other hand, OnToolTip seems to work just fine from standalone (non-prototype) elements, such as UIPane or UIButton elements that aren't part of a UIListBox.

This is a really strange problem because I know I've seen this done in other projects, such as Drammel's Tome of Battle. I've also encountered the same problem with OnMouseEnter events. Any ideas? :(

#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Drammels fires a script for each tooltip event, so it's likely done different, and frankly his solution is not so good for a PW, lot of scripts firing when players quickly run their mouse over a series of UI elements.

Listboxes, and refering to things in them, well it makes a lot of things not work which would work other wise. This is to be expected as it can't refer to something absolute, it has to refer to something relatively. I imagine you would/should store the value as a variable in the list box row - use the function to create to row to set the variables INSIDE the row, then in the tooltip, scrape the value from the UI row itself and set it to local:900 or the like, then use local:900 as the string value for the tooltip ( or some other high number which nothing else will use, i know 999 tends to be used for storing the reference to the player who owns the UI, at least i've seen that so i am trying to follow it ).

I found i had to make the listbox row selected on clicking it for anything to work, then i can grab the variable from what is selected, but this caused other issues. ( skills panel on my character editor which is on the citadel has example of this. ). There is a property which allows this, might be the issue you are having.

Will that work, no idea, but that is what i am planning to do with drammels tooltips to prevent a lot of extra scripts from firing when they don't need to.

The UI coding is 90% trial and error, a bit of prayer, some foul language and if you are doing something that does not work it's likely no one has tried it yet before.

I'd post more details on what you are doing. Actually i'd say when you get something working, post it as is, i've been doing that at the citadel and i am constantly referring to my own old posts. I am actually slowly trying to get grinning fools and sunjammers information, and what i know into a java doc format just so i have it right where it needs to be.

#3
MasterChanger

MasterChanger
  • Members
  • 686 messages
Thanks, Pain.

Drammel fires a script on every OnMouseEnter to update a string which the OnToolTip calls. I know it's not the best way, and like you I've been working with values retrieved from the selected row or something like that (I learned about that from Sunjammer's excellent UIListBox guide).

However, I have had trouble calling any function from the OnToolTip event at all, separate from whether I can get UIObject_Tooltip_DisplayTooltipString to work. I can get DisplayTooltipString to work from other events, but not from OnToolTip--if it's within a listbox. For example:

<UIListBox name="blah_list">
<UIButton name="blah_button" prototype=true OnLeftClick=UIObject_Tooltip_DisplayTooltipString("blah","OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")/>
</UIListBox>


I've taken a lot of shortcuts with that snipet, but it displays (probably) a tooltip with the text of "blah" when you left-click on the button. If I put that same function OnToolTip, it won't. However, if I have the same button outside a ListBox, it will display a tooltip from OnToolTip just fine! Makes no sense.

#4
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
First put a local:900 instead of blah.

It has to be a variable or there is not much point.

Second, make the line selectable.

This is done by doing this ->
<UIListbox name="SKILLPANE_LIST" ...snip... selectonleftclick="true" >

Finally refer to the value like this which grabs variable 6 from the listbox item and puts it in local:900, it's ok since it can repeatedly do this. Note i am doing this with OnLeftClick and not OnToolTip at present which might be a huge issue, but tooltips might be doable with onleftclick,who knows.
OnToolTip0=UIObject_Misc_ExtractData(selected:SKILLPANE_LIST,"string",6,local:900)
OnToolTip1=UIObject_Tooltip_DisplayTooltipString(local:900,"OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")

To set this variable, you do it when you create the row, the parameter for variables is set like this -->

string sVariables = "5="+sRowName+";6="+sRow;

Its basically a string, set like this it would put the row number in 6, and the row name in 5, and my above scraping is pulling from 6 so it would get the sRow value for the tooltip.

I use these as follows ( ignoring most of it except sVariable of course )

AddListBoxRow(oPC,sScreenName,"SKILLPANE_LIST",sRowName,sFields, sTextures,sVariables,sHide);

or

ModifyListBoxRow(oPC,sScreenName,"SKILLPANE_LIST",sRowName,sFields, sTextures,sVariables,sHide);


That is how i am kind of doing it now for skills, but i am also basing this on drammels tooltips, and kind of merging the two, i am just speculating, but it's kind of what i plan on doing eventually to replace how drammel is doing it. Selected is key, it's the only way i know which row is being clicked on/selected as such this might now work unless that is there.

I really need a way to refer to the current listbox row besides selected property, self: did not seem to work, but this is like anything else, it's something you just got to trial and error with until you find a way to get the result that you wanted.

Modifié par painofdungeoneternal, 03 avril 2011 - 08:31 .


#5
MasterChanger

MasterChanger
  • Members
  • 686 messages

painofdungeoneternal wrote...

First put a local:900 instead of blah.

It has to be a variable or there is not much point.

Second, make the line selectable.

This is done by doing this ->
<UIListbox name="SKILLPANE_LIST" ...snip... selectonleftclick="true" >


Yup, I learned this from Sunjammer's guide and am already doing it.

Finally refer to the value like this which grabs variable 6 from the listbox item and puts it in local:900, it's ok since it can repeatedly do this. Note i am doing this with OnLeftClick and not OnToolTip at present which might be a huge issue, but tooltips might be doable with onleftclick,who knows.
OnToolTip0=UIObject_Misc_ExtractData(selected:SKILLPANE_LIST,"string",6,local:900)
OnToolTip1=UIObject_Tooltip_DisplayTooltipString(local:900,"OBJECT_X","OBJECT_Y","SCREEN_TOOLTIP_2")


You can use DisplayTooltipString from OnLeftClick, yes. I have not been able to make any OnToolTip events work from a listbox row, so it might have to be OnLeftClick, in fact.

To set this variable, you do it when you create the row, the parameter for variables is set like this -->

string sVariables = "5="+sRowName+";6="+sRow;

Its basically a string, set like this it would put the row number in 6, and the row name in 5, and my above scraping is pulling from 6 so it would get the sRow value for the tooltip.

I use these as follows ( ignoring most of it except sVariable of course )

AddListBoxRow(oPC,sScreenName,"SKILLPANE_LIST",sRowName,sFields, sTextures,sVariables,sHide);

or

ModifyListBoxRow(oPC,sScreenName,"SKILLPANE_LIST",sRowName,sFields, sTextures,sVariables,sHide);


Yes, that was stuff that I had no idea about until I read Sunjammer's guide. Again, there's no issue with OnLeftClick working from these rows, but OnToolTip hasn't seemed to fire from a ListBox row. For stuff that you want to be able to identify before you click on it, this is unfortunate.

I'll try to get on IRC soon to talk about this.

#6
MasterChanger

MasterChanger
  • Members
  • 686 messages
This is somewhat bizarre. So far, it also seems that OnMouseEnter and OnRightClick events don't work (as in don't call assigned functions correctly) when they are placed on prototype elements within ListBoxes. OnLeftClick and OnLeftDoubleClick, however, work just fine.

I've also played around with capturemouseclicks=true or false and selectonleftclick=true or false (I know it needs select needs to be true to get data from the row, I was just messing around with it on someone's suggestion). These changes didn't make the events I list above work.

Clearly, the more events are available, the greater the GUI's potential power. I think that unfortunately, the model of using ListBoxes as dynamic collections of a huge variety of objects falls down a little bit, because OEI really used ListBoxes for only a small number of purposes: 1) a bunch of rows of text (like chatboxes) and 2) a list of attributes like feats that could be clicked on or dragged but wouldn't offer a great deal of functionality until you did something with them (put them on a hotbar or something).

#7
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
The thing is the UI was not made for you, it was made so they could implement the game itself. By the time folks figured out how to use it, well 1.23 was out and it was past the time it could be fixed. The learning curve is very steep.

It's not a well rounded general purpose programming environment, however it lets us do a lot more than we can in other games or NWN1. If they did a few more expansions then it might have ended up being more general purpose, nwscript actually had 6 versions (counting nwn1 and nwn2, but it also is used in other games made by bioware ) but still it was the few functions grinning fool added in 1.23 which really made nwscript finally reach it's full power.

The fact it does not work is entirely predictable, we just need to make notes of what works with what at some point, and get better documentation community side.

Modifié par painofdungeoneternal, 03 avril 2011 - 11:26 .