Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Key in DropList cannot be same
icon9.gif  Key in DropList cannot be same [message #14146] Fri, 15 February 2008 05:55 Go to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
ezcomm/main.cpp line 209
i have a DropList hist_text_in. Its values are received messages and its keys are indexes in a corresponding address list. Thus, different items in the DropList can have same keys to point to same indexes. But when I select an item, if keys are same, I cannot locate the item using GetIndex() + GetValue() or anything.
then i suppose i should have another list/table correlating each address list index to DropList key. in this way, key can be made unique. but when the DropList is full, new items make old items disappear. thus i have no easy way to track items.
  • Attachment: ezcomm.zip
    (Size: 330.42KB, Downloaded 263 times)
Re: Key in DropList cannot be same [message #14152 is a reply to message #14146] Fri, 15 February 2008 16:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Could you give me a pointer where to look? I see 3 DropLists, all empty.

Mirek
Re: Key in DropList cannot be same [message #14177 is a reply to message #14152] Mon, 18 February 2008 07:22 Go to previous messageGo to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
input your IP, port, IP, port from left to right.
keep UDP selected.
write sth.
press "send"
the message is then sent through the network loop and received at the right side.

send multiple messages. then choose one from the DropList on top of the incoming message text field.
whatever you choose, the first message will be shown, because of the location/key problem.

explanation: the incoming message history DropList's key is the peer's index in another std::list. So messages from same peers have same keys and there is no way to differ them by Find() or GetIndex(). The only way is to go through all the items.

hope i've made it clear. thank you.
Re: Key in DropList cannot be same [message #14198 is a reply to message #14177] Tue, 19 February 2008 22:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I am sorry. I have spent about 30 minutes trying to figure out what is the problem here, to no avail.

Perhaps more simple testcase and explanation would make me understand.

Mirek
icon14.gif  Re: Key in DropList cannot be same [message #14207 is a reply to message #14198] Wed, 20 February 2008 03:22 Go to previous messageGo to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
simplified
do not spend so long time figuring it out, just ask me to clarify next time. i've already been grateful.
  • Attachment: test.zip
    (Size: 2.55KB, Downloaded 242 times)
Re: Key in DropList cannot be same [message #14227 is a reply to message #14207] Wed, 20 February 2008 14:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
bonami wrote on Tue, 19 February 2008 21:22

simplified
do not spend so long time figuring it out, just ask me to clarify next time. i've already been grateful.


First

GetKey(l.GetIndex())

is (almost) the same as

~l

(but AFAIK, l.GetIndex can return -1, which will crash here).

Second, I start to realize the problem. Yes, "GetIndex" in fact searches for the first key that is equal. Solution is simple - do not put equal keys into DropList Wink

You can solve your problem by adding separate mapping array (keys are then indicies to this array).

Mirek
Re: Key in DropList cannot be same [message #14255 is a reply to message #14227] Thu, 21 February 2008 02:24 Go to previous messageGo to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
ok. then we've come to the place i first raised the post.
i thought DropList could be full just like WithDropChoice<> and old items might be replaced silently and synchronizing this (old items being deleted) to my "mapping array" would be tough.
but i seemed to be wrong. DropList has no size control, right? so it is all up to me.

[Updated on: Thu, 21 February 2008 03:58]

Report message to a moderator

Re: Key in DropList cannot be same [message #14279 is a reply to message #14255] Thu, 21 February 2008 16:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
bonami wrote on Wed, 20 February 2008 20:24

ok. then we've come to the place i first raised the post.
i thought DropList could be full just like WithDropChoice<> and old items might be replaced silently and synchronizing this (old items being deleted) to my "mapping array" would be tough.
but i seemed to be wrong.


Yes, usually in cases like this, I "ClearList" and refill (using "Add") after each program state change.

Quote:

DropList has no size control, right? so it is all up to me.


Size of what? Smile It has "SetDropLines".

Mirek
Re: Key in DropList cannot be same [message #14303 is a reply to message #14279] Fri, 22 February 2008 02:55 Go to previous message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
i'm totally clear now. thank you.
i do not care so much about how many items can be shown without scrolling/sliding.
Previous Topic: Two questions on U++
Next Topic: Layout and Paint event processing
Goto Forum:
  


Current Time: Fri Mar 29 03:09:03 CET 2024

Total time taken to generate the page: 0.01529 seconds