|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
uh uh now i am confused
isnt ,0 = no line and ,1 = some line ?
and my goal is to button disable ONLY if there is nothing in listbox
coz when i remove all from list, the button is still enabled
Last edited by raZOR; 11/05/06 05:44 PM.
IceCapped
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
1 is true, 0 is false.
You're checking to see if the control does have a value. When you should be checking to see if the control doesn't have a value.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
No, you should read the help file on $did().sel (and in fact the entire page on dialogs). Also, when you don't know what something does exactly, USE /echo. Bold cannot stress this enough, /echo is the best way to figure out how stuff works.
$did(name,id,0) -> total number of selected lines $did(name,id,1) -> index of 1st selected line $did(name,id,2) -> index of 2nd selected line
Inside an on DIALOG event $did(name,id,N) can be $did(id,N)
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
so then
this : if (! $did(46,0 ).sel) { .did -b protect 49 } is equal to this? if ($did(46,1 ).sel) { .did -b protect 49 }
?
IceCapped
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
"$did(name,id,0) -> total number of selected lines"
then by some logic it should be
if ($did(name,id,0) == 0) { disable coz it has no lines } no?
anyways that code by hixxy (last) and Slade works. i just now want to figure out this logic coz it has no sence to me
Last edited by raZOR; 11/05/06 05:59 PM.
IceCapped
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Yes. if ($did(name,id,0) == 0) is the same as if (!$did(name,id,0))
which is what hixxy used
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
ehm i just noticed that code actually doesnt work for me @qwerty so if that is true: if ($did(name,id,0) == 0) then why my button does NOT get disabled when nothing is in list control ?
IceCapped
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
if ($did(name,id,0)[color:red].sel[/color] == 0) Sometimes, people on here make mistakes in their posts or assume you know what to do and write shorthand versions. It's ok to try and correct things yourself sometimes.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Oops, I guess I copied raZOR's mistake, thanks.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Np Happens to everyone.
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
hmm there is 1 odd thing happen when i click on list but not ON content (like if i have added 3 lines of something, so i click below them) list PASSIVE selects some line and on execution (button) button get disabled yes, it works when ACTIVE selected line, but why it disables on PASSIVE select ?
IceCapped
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Eh? Could you rephrase that?
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
when listbox is PASSIVE selected and i click on remove button, button is disabled and ofcourse nothing is removed from list . so why this happen (disables button) if i didnt selected anything ?
Last edited by raZOR; 11/05/06 07:28 PM.
IceCapped
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Because nothing is selected. One of the items has focus, but it's not selected.
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
uh oh...
so while trying to have checkup if no lines are in list it disables button but in same time if nothing is selected even there are things to select it disables button again...
lol?
so is this like.. only way it can be ?
IceCapped
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
uh oh...
so while trying to have checkup if no lines are in list it disables button but in same time if nothing is selected even there are things to select it disables button again...
lol?
so is this like.. only way it can be ? I would say no it doesnt require that something be selected, I have not tested it though. post your code here and one of will have a solution. However I think you cant check to see if ID 46 has any lines on :dialog:NAME:sclick:46:{ if ($did(!$dname,46).lines) { did -b $dname 49 } else { did -e $dname 49 code to do something with $did(46).seltext }
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
well if it cannot be done, then i dont wish to bug people :P ill choose then most fitting solution form all previous givent codes and suggestions. so i say thanks to all who helped me here thank you.
IceCapped
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
does this do what you want to do? sample
dialog list {
title "List Box"
size -1 -1 200 100
option dbu
list 100, 20 20 160 60
button "Add", 900, 30 75 60 10
button "Remove", 901, 110 75 60 10
}
;; disable the remove button when starting
on *:dialog:list:init:0:{
did -b list 901
}
;; Add something to the listbox,
;; and if something is added, enable the remove button
on *:dialog:list:sclick:900:{
if ($cb(0)) {
did -a list 100 $cb
did -e list 901
}
}
;; Remove a line from the list
;; if the list is empty, disable the remove button
on *:dialog:list:sclick:901:{
did -d list 100 $did(list,100).sel
if (!$did(list,100).lines) { did -b list 901 }
}
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
yes exactly that, and it works except i get error /did invalied parameters for
did -d something 100 $did(list,100).sel
when list control is passive selected
IceCapped
|
|
|
|
|