开发者

Cocoadialog dropdown with array as list

Why is the foo element not included?

items=(  "invisible below" foo "invisible above" "bar" "foo" not invisible )
# invisible:                ^
CocoaDialog standard-dropdown --text "Choo开发者_开发知识库se:" --items "${items[@]}" --string-output --float --debug


The problem is that CocoaDialog loads the list of values into an array in which the keys and values are the same. It essentially sees foo and "foo" as them same item, the second one will overwrite the first - much like an array in PHP.

So, if you change your array to this:

items=(  "invisible below" foo1 "invisible above" "bar" "foo" not invisible )

You'll see that foo1 shows up:

image http://img269.imageshack.us/img269/6738/screenshot20110818at223.png

The reason we know that it is CocoaDialog and not bash is that we can print out the array of items:

$ items=(  "invisible below" foo "invisible above" "bar" "foo" not invisible )

$ printf "%s\n" "${items[@]}"
invisible below
foo
invisible above
bar
foo
not
invisible

So, the array that you're passing is fine - CocoaDialog is just overwriting the first value with the second one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜