| View previous topic :: View next topic |
| Author |
Message |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Mon Jan 17, 2011 1:24 pm Post subject: Table positioning |
|
|
I have a script that manages a playlist of MP3 and It's playing one by one.
To display the playlist I use a table with the names of each track.
Each time you change tracks the cursor is changing in the table. To do this, I use "List Seek" and/or the @match() function, but the preselection in table (a line box dotted) is still in the first row while the selection has changed
Is there any way to get it correctly?
This is a little example:
| Code: |
DIALOG CREATE,New,-1,0,600,308
DIALOG ADD,STYLE,StyleFB,,18,,004080,WHITE
DIALOG ADD,TABLE,TABLE1,137,42,490,144,Column 1[250],,StyleFB
DIALOG SHOW
list add,table1,Track-1
list add,table1,Track-2
list add,table1,Track-3
list add,table1,Track-4
list add,table1,Track-5
list add,table1,Track-6
list add,table1,Track-7
list add,table1,Track-8
list seek,table1,1
wait 5
window send,New,@key(down)
wait 5
list seek,table1,3
wait 5
if @match(table1,Track-7)
wait 5
end
|
|
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Jan 17, 2011 3:45 pm Post subject: |
|
|
Your script changes the highlighted item on my machine just fine.
If what you are trying to do is make sure that a searched or selected item is visible in the list. You can use an API call to the table.
The macro is called "LVM_ENSUREVISIBLE"
| Code: | DIALOG CREATE,New,-1,0,600,308
DIALOG ADD,STYLE,StyleFB,,18,,004080,WHITE
DIALOG ADD,TABLE,TABLE1,137,42,490,144,Column 1[250],,StyleFB
DIALOG SHOW
list add,table1,Track-1
list add,table1,Track-2
list add,table1,Track-3
list add,table1,Track-4
list add,table1,Track-5
list add,table1,Track-6
list add,table1,Track-7
list add,table1,Track-8
list seek,table1,1
REM The following will ensure that the current index of table1 is visible
REM LVM_ENSUREVISIBLE = $1013
%x = @sendmsg(~table1,$1013,@index(table1),0)
wait 3
list seek,table1,3
%x = @sendmsg(~table1,$1013,@index(table1),0)
wait 3
if @match(table1,Track-7)
%x = @sendmsg(~table1,$1013,@index(table1),0)
wait 3
end |
|
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Mon Jan 17, 2011 4:51 pm Post subject: |
|
|
Thanks Aslan!! I will try this API, but note that if you seek in table and you press a key (up or down) the pointer appears from 0 and not from the highlighted item.
The only way to change that "dot pointed pre selection" is with up/down or mouse, not by seek or @match()
The API call to ensure the visibility of items works fine!
Sorry, my english is poor to explain it better.... |
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Tue Jan 18, 2011 5:14 pm Post subject: |
|
|
| Is there any way to send a click to this specific line of the table to solve this problem? |
|
| Back to top |
|
 |
uvedese Contributor


Joined: 21 Jan 2006 Posts: 169 Location: Spain
|
Posted: Tue Jan 18, 2011 6:04 pm Post subject: |
|
|
Hi!
Perhaps using "Window click" command?
You must calculate position of a row in table, based on its coordinates "top" and "left".
It's not exact but it may working.
Good luck!
Cordially.
_____________
uVeDeSe
_____________ |
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Tue Jan 18, 2011 6:10 pm Post subject: |
|
|
Thanks Uvedese, but i dont understand how to calculate the position of this row in the screen to send it a click.
I will start to play with this anyway  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Jan 19, 2011 4:00 am Post subject: |
|
|
| marcelo wrote: | I will try this API, but note that if you seek in table and you press a key (up or down) the pointer appears from 0 and not from the highlighted item.
The only way to change that "dot pointed pre selection" is with up/down or mouse, not by seek or @match() |
Maybe I'm not sure what you are trying to explain but "List Seek", @match() and using the up/dn arrow keys does change the index pointer. You just have to keep checking to see if it has changed.
The following example shows this. Keep an eye on the Status bar.
| Code: | TITLE "Play List"
DIALOG CREATE,Play List,-1,0,512,308
DIALOG ADD,STYLE,StyleFB,,,,004080,WHITE
DIALOG ADD,BUTTON,Search,256,202,56,24,Search,,DEFAULT
DIALOG ADD,TABLE,TABLE1,13,11,490,234,Track[250]|Length,,StyleFB
DIALOG ADD,EDIT,SearchEdit,260,12,180,19,<Enter Search>,,CLICK
DIALOG ADD,BUTTON,Random,257,363,64,24,Random
DIALOG ADD,BUTTON,Sequential,257,437,64,24,Sequential
DIALOG ADD,STATUS,STATUS1,
DIALOG SHOW
Dialog disable,Search
REM Build sample Play List in TABLE1
%n = 0
Repeat
%n = @succ(%n)
list add,TABLE1,Track-%n@tab()@random(1,7):@random(0,9)@random(0,9)
Until @equal(%n,20)
list seek,TABLE1,0
REM The following will ensure that the current index of TABLE1 is visible
REM LVM_ENSUREVISIBLE = $1013
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
:evloop
REM Check every 0.05 sec to see if the TABLE1 index has changed
# The extra param after "wait event" will cause the TIMER event
wait event,0.05
goto @event()
:Timer
REM Show current index in the status bar
Dialog set,status1,@item(TABLE1)
goto evloop
:RandomBUTTON
%E = @event()
Repeat
list seek,TABLE1,@random(0,20)
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
%E = @event()
wait 1
Until %E
goto %E
:SequentialBUTTON
%E = @event()
%s = 1
list seek,TABLE1,0
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
wait 1
Repeat
list seek,TABLE1,%s
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
%s = @succ(%s)
wait 1
Until @equal(@count(TABLE1),%s)
goto evloop
:SearchBUTTON
%i = @index(TABLE1)
List seek,TABLE1,0
If @match(TABLE1,@dlgtext(SearchEdit))
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
else
List seek,TABLE1,%i
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
end
goto evloop
:SearchEditCLICK
dialog enable,Search
dialog set,SearchEdit,
goto evloop
:Close
exit |
|
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Wed Jan 19, 2011 2:12 pm Post subject: |
|
|
Thanks a lot Aslan!!! Your script is perfect! My script do the same but with more lines of code because you know what to do
What i'm trying to explain is this:
Imagine you are using this script and you have a remote control in your hand with the UP/DOWN/ENTER keys programmed on it.
You have a very very large number of MP3 files, you choose sequential play in your script and you enjoy your favourite music....
This is perfect, but imagine that while playing track-40 you remember that you hate songs 40, 41 and 42, so you press down to position the cursor over track 43 and press enter on it to play this song and the followins.
Try to do this with your script while playing track 15 (for example) or when the list ends, press down key and you'll note the cursor starts from track 1 again. This is not a big troble, but if you have a very large list of songs....
and.... THANKS!!! THANKS!!! THANKS!!!! A LOT!!! for your patience on help me with the script and trying to understand my english  |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Wed Jan 19, 2011 2:14 pm Post subject: |
|
|
I think the difficulty lies in the difference between highlighting and selecting. As an example, Aslan, start your program and click the sequence button. As the 5th item gets highlighted, click on the 3rd item. The sequencing continues, but item 3 remains "selected".
I think Uvedese is correct, you will have to create mouse clicks to "select" the item you need...
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Wed Jan 19, 2011 2:37 pm Post subject: |
|
|
| Hooligan wrote: | | I think the difficulty lies in the difference between highlighting and selecting. As an example, Aslan, start your program and click the sequence button. As the 5th item gets highlighted, click on the 3rd item. The sequencing continues, but item 3 remains "selected". |
YES! This is what i'm trying to say
Thanks Hooligan! |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Jan 20, 2011 4:56 am Post subject: |
|
|
The issue is actually that you have to constantly check for events.
The reason is that when clicking sequence VDS won't do anything until the sequence is complete. Remember VDS is only a single theaded interpreter.
I have modified the script to react to events while running the sequence or random selection. While in "Sequential" or "Random" Double-Click on an item and it will react to it and then resume what it was doing. Also, when your actually using MCI calls you won't be using the "Wait" command as I did in this example just to show effect.
| Code: | TITLE "Play List"
DIALOG CREATE,Play List,-1,0,512,308
DIALOG ADD,STYLE,StyleFB,,,,004080,WHITE
DIALOG ADD,BUTTON,Search,257,202,56,24,Search,,DEFAULT
DIALOG ADD,TABLE,TABLE1,13,11,490,234,Track[250]|Length,,StyleFB,DBLCLICK
DIALOG ADD,EDIT,SearchEdit,260,12,180,19,<Enter Search>,,CLICK
DIALOG ADD,BUTTON,Random,257,363,64,24,Random
DIALOG ADD,BUTTON,Sequential,257,437,64,24,Sequential
DIALOG ADD,STATUS,STATUS1,
DIALOG ADD,BUTTON,Stop,257,277,64,24,Stop
DIALOG SHOW
Dialog disable,Search
REM Build sample Play List in TABLE1
%n = 0
Repeat
%n = @succ(%n)
list add,TABLE1,Track-%n@tab()@random(1,7):@random(0,9)@random(0,9)
Until @equal(%n,20)
list seek,TABLE1,0
REM The following will ensure that the current index of TABLE1 is visible
REM LVM_ENSUREVISIBLE = $1013
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
:evloop
REM Check every 0.05 sec to see if the TABLE1 index has changed
# The extra param after "wait event" will cause the TIMER event
wait event,0.05
goto @event()
:Timer
REM Show current index in the status bar
Dialog set,status1,@item(TABLE1)
goto evloop
:RandomBUTTON
%%seq = 0
%%rand = 1
%E = @event()
:ResumeRandom
Repeat
list seek,TABLE1,@random(0,20)
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
wait 2
%E = @event()
If @both(%E,@unequal(%E,TIMER))
until 1
goto %E
end
Until %E
goto %E
:SequentialBUTTON
%%seq = 1
%%rand = 0
%E = @event()
%E =
%s = 1
list seek,TABLE1,0
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
wait 2
:ResumeSequence
Repeat
list seek,TABLE1,%s
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
%s = @succ(%s)
wait 2
%E = @event()
If @both(%E,@unequal(%E,TIMER))
until 1
goto %E
end
Until @equal(@count(TABLE1),%s)
goto evloop
:TABLE1DBLCLICK
Dialog set,status1,@item(TABLE1)
%s = @index(TABLE1)
If @equal(%%seq,1)
Dialog set,status1,@item(TABLE1)@tab()Resuming Sequence in 2 sec
wait 2
goto ResumeSequence
end
If @equal(%%rand,1)
Dialog set,status1,@item(TABLE1)@tab()Resuming Random in 2 sec
wait 2
goto ResumeRandom
end
goto evloop
:SearchBUTTON
%i = @index(TABLE1)
List seek,TABLE1,0
If @match(TABLE1,@dlgtext(SearchEdit))
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
else
List seek,TABLE1,%i
%x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0)
Dialog set,status1,@item(TABLE1)
end
goto evloop
:SearchEditCLICK
dialog enable,Search
dialog set,SearchEdit,
goto evloop
:StopBUTTON
%%seq = 0
%%rand = 0
goto evloop
:Close
exit |
The best way to understand this script is to step through it. |
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Sun Jan 23, 2011 3:17 am Post subject: |
|
|
No, it doesn´t works. But no problem: If it's not posibble... it's not posibble.  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sun Jan 23, 2011 5:34 am Post subject: |
|
|
| What part doesn't work. The example works perfectly on my machine. |
|
| Back to top |
|
 |
marcelo Contributor


Joined: 10 May 2008 Posts: 155
|
Posted: Mon Jan 24, 2011 2:47 am Post subject: |
|
|
Start the program, Press "Sequential" button, wait for the list to end or press Stop in track 15 (for example).
Press down key to browse the list and tell me where the cursor start from. |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Jan 26, 2011 8:12 pm Post subject: |
|
|
Quick guess..
Under each: | Code: | | %x = @sendmsg(~TABLE1,$1013,@index(TABLE1),0) |
Add: | Code: | | %x = @sendmsg(~TABLE1,$1060,@index(TABLE1),0) |
That's the ID for LVM_SETHOTITEM.. like I said just a guess. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|