Topic: UI Listbox trouble Pages that link to <a href="https://ozoneasylum.com/backlink?for=11423" title="Pages that link to Topic: UI Listbox trouble" rel="nofollow" >Topic: UI Listbox trouble\

 
Author Thread
mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 05-30-2003 15:22 Edit Quote

I am using Flash MX to create some software simulation for training purposes. I'm trying to demonstrate a navigation functionality.

Here's what I want the user to accomplish:
1) place cursor in a text entry box and enter letters
2) when the right combination of letters ('md') is entered, I want a previously not-visible UI listbox to become visible, get the focus, and have item [0] selected.
3) The user will then use keyboard arrows to select the appropriate list item and push the enter key.

What I've Done:
I've added a listener to the textbox. onKeyUp I check the value of the textbox and if it == 'md' then I removeListener, set listbox._visible=true, set listbox selection Index to 0, and give it the focus.

Problem:
One would think that the user should be able to then push the down arrow on the keyboard to move the selection to item 1, again to item 2, etc.
That is not the case! The user must push the arrow key TWO times before the listbox responds! Once the arrow key is pressed two times, everything works great, but it does not respond to the first push of the arrow key.

Why? and what can I do to fix this?

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 05-30-2003 22:02 Edit Quote

That sounds like it might be a bugger to track down. What have you done so far in terms of diagnostics?

Only thought I have is this: you have given the listbox focus, but that my not by default select the item at index 0. So the first press of the arrow actually selects item zero, which is why it takes a second press to select item 1. Keep in mind - this is just my best guess! But you could throw in a trace when you give the listbox focus to see what is actually selected; something along the lines of

trace( myList_lb .getSelectedItem());

if it returns 0 my guess is wrong. If it returns undefined or something like that, you will have to add a line of code to select index 0 immediately after you give the list box focus:

myList_lb. setSelectedIndex(0);

Hope that's a help

Oh - and I forgot - I was going to suggest that the onChanged event handler of the textField object might be easier than the keyUp approach you are using. Something along the lines of this rough idea:

code:
yourInput_txt.onChanged = function (changedField) {
if (this.text == "md") {
do some stuff;
}
}



[This message has been edited by Steve (edited 05-30-2003).]

mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 06-02-2003 15:01 Edit Quote

I've thought about the focus and I've thought about which item is selected. It's interesting, after I wrote originally I went back and tested starting the selection somewhere besides item[0] and see what happens.

It is as if the damn thing needs a 'kick' to wake it up, and that kick is an active key.
When I start at item[0], the down arrow and end keys act as the 'kick', then anything after that will work.
When I start at item[n] (where n is not the first or last), the down arrow, up arrow, end key and home key all act as the 'kick', then any normal working key after that will work.
When I start at item[x] (where x is the last), only the up arrow and home key will act as the 'kick'.

I tried using the onChanged for the textbox and ran into another problem. The way this is set up, I have frames 1-10 as an introduction, frames 11-20 as lesson 1, 21-30 as lesson 2, etc. Lesson 1 is a lesson on using the main 'left nav' navigation. Lesson 2 is this bloody 'shortcut' navigation described above.
If the user goes in order Introduction, Lesson 1, 2,3,4 etc. everything works great. The problem is, when the user wants to repeat lesson 2 (user clicks 'repeat' button, gotoandPlay(21), set textbox variable back to "") the onChanged event won't fire the second time through.
I've attached a trace to the onChanged and to a seperate onKeyUp. Both read the value of the text box. onKeyUp shows that the variable is, indeed, changing. onChanged won't fire.

I replaced the onChanged with onKeyUp, kept everything else the same, and now it works perfectly.

The funny thing is, when I was using the onChanged, I didn't have the listbox troubles. Now using the onKeyUp, it works great on repeat, but I have listbox troubles.

For now, I've added a third listener that looks only for arrow down. After the list box is visible and has focus, on the first arrow down, I move the selection to item[1], and removeListener. This both moves the selection (as a user would expect) and it provides the 'kick' needed to make further key presses actually do something.
While it works, it's not pretty.

You know what? It's first thing in the morning and I haven't gotten my coffee yet. Give me an hour and I'll see if I can find someplace to put up my flash file for you all to dig through.
Thanks

[Edit: coffee down, mobrul happy.]

Flash file, zipped
My problems happen at frames 20 and 21. Remember, this is a WIP.

[This message has been edited by mobrul (edited 06-02-2003).]

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 06-03-2003 05:02 Edit Quote

mobrul - it's going to be a day or two before I can look at the file. Just want you to know I'm not ignoring you - sorry!

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 06-06-2003 21:13 Edit Quote

mobrul;

I had about an hour last night to look at the fla, and that's about how long it took me to figure out what was going on in the movie as a whole (I'm terrible at trying to read other people's code - reading my own is bad enough!)

That wasn't enough time to figure out what the problem was, but at least I know my way around the movie now. I'm willing to spend some more time poking at it, but not if you're already figured it out. What's your debug status currently? Still an issue or is it fixed?

Sorry to be so long getting back to you. Killer week, this was.

mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 06-06-2003 23:05 Edit Quote

No problem at all. You're helping me, remember. No need to apologize.

Status:
stupidListener provided a reasonable workaround. I don't like it, but it works. I can live with that.
As a point of understanding Flash and actionscript better I'd really like to understand what in the hell is going on, but that's a secondary concern to the primary concern of getting this thing to the customer. As it stands, I can get a product to the customer.

If you have some time to go through it, by all means, please do. I value your opinion as a Flash guru and I'd be honored (fancy language, but I really mean it) to have your help and advice on my side.
If you don't have time, no worries.

Either way, thanks for the effort you've given so far.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu