scrolling list / data grid question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
scrolling list / data grid question
I've got a scrolling list that's populated with the names of reference tables that I have for my application. Depending on which reference table the user chooses, they can edit, delete or add a record to the specific reference table.
Right now I have a list of the reference tables (there are three of them) in a scrolling list box. My question is, what command do I use to allow the user to scroll through the box and choose one of the reference tables. I've tried mouseUp, mouseDown, keyDown and menuuScript. None of them will allow someone to choose one of the three reference tables. I'll even change the scroll list to a data grid if that helps. If I change to a data grid, my question remains the same.
As a test to make sure that the code does what I want it to do I've got a switch statement and inside each option (whether the user chooses reference table 1, 2 or 3) is an answer statement that tells me that the switch statement works.
Once the user chooses one of the reference tables, I want to populate the reference table in a data grid and allow them to add, edit or delete rows in the table.
Thanks,
Peter
Right now I have a list of the reference tables (there are three of them) in a scrolling list box. My question is, what command do I use to allow the user to scroll through the box and choose one of the reference tables. I've tried mouseUp, mouseDown, keyDown and menuuScript. None of them will allow someone to choose one of the three reference tables. I'll even change the scroll list to a data grid if that helps. If I change to a data grid, my question remains the same.
As a test to make sure that the code does what I want it to do I've got a switch statement and inside each option (whether the user chooses reference table 1, 2 or 3) is an answer statement that tells me that the switch statement works.
Once the user chooses one of the reference tables, I want to populate the reference table in a data grid and allow them to add, edit or delete rows in the table.
Thanks,
Peter
Re: scrolling list / data grid question
Code: Select all
on selectionchanged
answer the selection
end selectionchanged
I'll note that the message/event is generated even if the selection hasn't changed. So, if the selection is currently the first item, and the user clicks on the first item again, the handler is called.
Re: scrolling list / data grid question
In the property inspector, set the listbehavior, locktext, and the dontwrap to true. That will make the field act like a selectable list. When the user clicks a line the field will get a selectionchanged message and also a mousedown, mouseup, etc. You can trap any of those and get the line number (the hilitedline) or the selectedtext.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: scrolling list / data grid question
Something isn't working properly (or maybe I just didn't explain what I wanted to do). The scrolling list has some options in it (reference tables that can be updated or changed). The inspector for the scrolling list has the listbehavior box, locktext box and don't wrap box checked.
When I click to go into the scroll list box the up and down arrow keys don't work. I can't move the from the highlighted field via the up and down arrow keys. In addition, when I choose a reference table to modify, edit, etc. the choice would be made by either pressing the return key or clicking on the mouse pad. Nothing seems to work.
I have three reference tables at this time. In the inspector I've named the variables ref_table. After I choose the reference table that I want to do work on, how can I get a case statement to work (i.e.
switch ref_table
case '1'
case '2'
case '3'
end switch
This format doesn't seem to work for me.
This has to be a concept that's used a lot.
Thanks in advance.
Peter
When I click to go into the scroll list box the up and down arrow keys don't work. I can't move the from the highlighted field via the up and down arrow keys. In addition, when I choose a reference table to modify, edit, etc. the choice would be made by either pressing the return key or clicking on the mouse pad. Nothing seems to work.
I have three reference tables at this time. In the inspector I've named the variables ref_table. After I choose the reference table that I want to do work on, how can I get a case statement to work (i.e.
switch ref_table
case '1'
case '2'
case '3'
end switch
This format doesn't seem to work for me.
This has to be a concept that's used a lot.
Thanks in advance.
Peter
Re: scrolling list / data grid question
Hi Peter,
you need to "close" each case with a "break!
If you omit the "break" ALL case will get executed one after another!
Best
Klaus
you need to "close" each case with a "break!
If you omit the "break" ALL case will get executed one after another!
Code: Select all
...
switch XYZ
case "1"
## Do your stuff...
break
case "2"
##...
break
case "3"
## ...
break
end switch
...
Best
Klaus
Re: scrolling list / data grid question
I know about the break statement. I can't get the case statement to work at all and I can't get the scrolling list to do what I want it to do.
Thanks
Thanks
Re: scrolling list / data grid question
Hi Peter,
OK, looks like I did not understand what your problem is.
But we need more info, what scripts have you used, what exactly is the content of your list field etc.
Best
Klaus
OK, looks like I did not understand what your problem is.
But we need more info, what scripts have you used, what exactly is the content of your list field etc.
Best
Klaus
Re: scrolling list / data grid question
What is the exact content of your scrolling field? I'm not sure what you mean by "reference tables"; are those just one-line strings?
What you want to do is pretty common and not difficult, so something else is interfering. Assuming that the field contains just a 3-line text list, then arrow keys should work to change the hilited line without any scripting. Selecting one of the lines to actually do something requires a script in the field. You can use a mouseup handler, for example, which will trap clicks:
and then you need a handler like this:
This will only respond to mouse clicks. If you want to respond to both clicks and arrow key selections, use "selectionChanged":
If you want to respond to the enter or return keys instead of just a change in hiliting, use enterInField and returnInField to catch those:
If you decide you want to respond to both enter/return keys as well as mouseclicks, use the above plus the mouseup handler in the field.
What you want to do is pretty common and not difficult, so something else is interfering. Assuming that the field contains just a 3-line text list, then arrow keys should work to change the hilited line without any scripting. Selecting one of the lines to actually do something requires a script in the field. You can use a mouseup handler, for example, which will trap clicks:
Code: Select all
on mouseUp
put the selectedtext of me into tTableRef
-- now do something with that text:
chooseTable tTableRef
end mouseUp
Code: Select all
on chooseTable pTable
switch pTable
case "myTable 1"
-- stuff
break
case "myTable 2"
-- stuff
break
case "myTable 3"
-- stuff
break
default
-- if you need one
end switch
end chooseTable
Code: Select all
on selectionchanged
put the selectedtext of me into tTableRef
chooseTable tTableRef
end selectionchanged
Code: Select all
on enterInField
put the selectedtext of me into tTableRef
chooseTable tTableRef
end enterInField
on returnInField
enterInField
end returnInField
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com