Detecting Programmatically Changed Text in a Listbox Cell

  1. 6 weeks ago

    Don L

    Jan 9 Pre-Release Testers, Xojo Pro Florence, South Carolina USA

    I'm well aware of the "CellTextChanged" event for listboxes. However, that event does NOT fire when you programmatically change the text contents of a listbox cell. There's several threads on the forum here that relate to this issue, but all of them that I found were at least several years old and none of them had a solution. I even thought I could be clever and use a combination CellGotFocus and CellLostFocus to do what I need (determine if the contents of a cell changed) but those events don't fire either when the cell is not set up to be "editable" (which in my case, they are not editable).

    Has anybody found a way around this?

    Thanks in advance for your consideration!

  2. Dave S

    Jan 9 San Diego, California USA

    So how is it you don't know WHEN the text is changed?
    At some point don't you have code similar to

    listbox1.cell(row,col)="new data"

    if so, just call your "textchanged" code at that point

  3. Norman P

    Jan 9 Pre-Release Testers, Xojo Pro outside listening to the silen...

    subclass listbox and override listbox1.cell(row,col)
    then you can tell

  4. Don L

    Jan 9 Pre-Release Testers, Xojo Pro Florence, South Carolina USA

    @Dave S So how is it you don't know WHEN the text is changed?
    At some point don't you have code similar to

    listbox1.cell(row,col)="new data"
    if so, just call your "textchanged" code at that point

    Thanks for the response, Dave. Although it's not quite that simple in my case, your input did redirect my focus to something I hadn't considered but does workaround the issue. The listbox cell in question is being fed data from a textfield where the user makes changes. Upon the textfield losing focus, it programmatically replaces the listbox cell contents. With your idea in mind, I can capture the existing listbox cell content upon entering the textfield with the textfield's GotFocus event and compare that to the textfield's text when the user leaves the textfield with the textfield's LostFocus event (which is when the programmatic change to the listbox cell occurs) to see if there was any change in the content.

    Thanks for the idea!

  5. Don L

    Jan 9 Pre-Release Testers, Xojo Pro Florence, South Carolina USA

    @Norman P subclass listbox and override listbox1.cell(row,col)
    then you can tell

    Thanks for taking the time to look at this and respond, Norman. I had a feeling that subclassing was going to be an answer, but I have minimal experience with it and the program I'm working on must be done by Monday in order to demo it at a customer's site. I'm just not sure how much time (study?) it would take me to do what I want and I'm running out of time as it is. You have, however, convinced me that it's the long term solution to my need (and others I'll face in the future, I'm sure). So, when I get back next week from my customer demo, I'm going to bite the bullet and sit down and learn what I need to in order to be able to do it. It's fair to say that that's one "education" that's long overdue.

  6. brian f

    Jan 9 Pre-Release Testers, Xojo Pro Chilly California

    Don,

    you will find subclassing in Xojo very intuitive. IDE file menu Inset -> Class, name it what you want then select the Super class (Listbox) and you will see your newly created class icon in the IDE change to that of a listbox.

    For overriding here is a good forum post Over Riding

  7. Don L

    Jan 9 Pre-Release Testers, Xojo Pro Florence, South Carolina USA

    @brian f For overriding here is a good forum post Over Riding

    Thanks so much, Brian! That forum post answers a number of the questions I had. I gave a quick look through the Xojo examples provided with the installation but didn't see anything about the topic. I know there's a couple of examples in the User's Guide but it's quite limited with little explanation. If you're aware of any other sources of subclassing educational material (e.g., "Subclassing for the Subclassing Challenged" or something like that :D ), I'd be most grateful if you passed it on to me.

  8. Julian S

    Jan 9 Pre-Release Testers, Xojo Pro UK

    Here you go Don, just a quick example, I hope it helps you, g'luck on Monday!

    https://www.dropbox.com/s/aqkw6d6a6cx34zl/TestListBoxCellChangeEvents.xojo_binary_project?dl=0

or Sign Up to reply!