Add/ModifyListBoxRow
#1
Posté 10 janvier 2011 - 02:02
I've looked at the code for both functions but I'm left less than completely enlightened.
#2
Posté 11 janvier 2011 - 06:39
What I'm trying to do is be able to have multiple textures per row, and be able to distinguish which ones was clicked on. If I can get the position of the cursor within the row (maybe as 0100010 mentions?) I should be able to figure out which member of the row the user clicks on.
My end-goal, by the way, is a replacement for the Quickspell GUI for a custom magic environment.
#3
Posté 13 janvier 2011 - 08:43
#4
Posté 13 janvier 2011 - 09:45
The tutorial you linked to is fairly old, but if I recall, pretty good (I don't think much has changed since v1.13 or whatever it was). Another good source is Rich Taylor's blog - he talks about listbox callbacks and functions on there.
#5
Posté 14 janvier 2011 - 12:24
The Fred wrote...
The listbox functions are especially useful - they're what I used for my resting GUI, amongst other things. You needn't use the mouse cursor to find which one was clicked, as you can set a local variable on each row and then have it be returned to a script when that row is selected. Or, you can in fact just send the currently selected row to a script when a button is pressed, I believe.
Yes, I learned from the tutorial that if you set selectonleftclick=true in the listbox, you can use listboxrow:[Name of your listbox] in function calls such as ExecuteServerScript or ExtractData.
The tutorial you linked to is fairly old, but if I recall, pretty good (I don't think much has changed since v1.13 or whatever it was). Another good source is Rich Taylor's blog - he talks about listbox callbacks and functions on there.
Yes, I've been going through that blog extensively. It's a very good reference, though it doesn't explain everything and it's better if you already know what you're looking for. I was remiss in not linking it here; a big part of why I'm continuing to post even if I'm answering my own questions is to potentially help people down the line.
So I'll also note some of my experience with trying to use ListBoxes to build 2d image arrays, since none of the examples I've seen explicitly deal with this. What I've found is that it's quite easy to add or modify rows based on the prototype one sets in the .XML, and you can tell which row has been clicked on or extract other data as we discussed above. However, you can't easily add columns (at least I haven't figured out how).
So, this means that if you have one dimension that's dynamic and one that's static and has a discrete order, it makes sense to make your dynamic stuff vertical and the static info horizontal. I learned the trick of making each column a listbox one button wide from Drammel's Quick-strike menu.
#6
Posté 14 janvier 2011 - 06:56
That said, depending on what you want to do, you could just create a grid object and handle each element individually. Through script you'd be able to set each square to have its own texture etc. The drawback of this is that if you want a large number of rows, you will have to hand-create the XML file rather than being able to use an NWScript loop (though I guess you might be able to use Excell or write a little program or something).
#7
Posté 16 janvier 2011 - 02:33
The Fred wrote...
That said, depending on what you want to do, you could just create a grid object and handle each element individually. Through script you'd be able to set each square to have its own texture etc. The drawback of this is that if you want a large number of rows, you will have to hand-create the XML file rather than being able to use an NWScript loop (though I guess you might be able to use Excell or write a little program or something).
Well, the grid won't work for the bit I'm working on, but I may want to use it for other aspects. I couldn't find any nwscript functions for UIGrid, though. I suspect they use prototypes as well...
#8
Posté 16 janvier 2011 - 11:08
#9
Posté 27 janvier 2011 - 01:36
Modifié par Sunjammer, 27 janvier 2011 - 01:43 .
#10
Posté 27 janvier 2011 - 02:33
Sunjammer wrote...
Oops: I posted a link to my guide and only then noticed you'd already found it.
Thanks, Sunjammer. That guide was exactly what I needed!





Retour en haut







