ListBox backgroundClicked doesnt work


#1

Hey guys

I have a standard class which looks as follows:

class StoryListBox2 : public ListBox, public ListBoxModel {

Nothing drastic has been changed, although I have defined my own listBoxItemClicked function. My problem is I am struggling to get the class to register when I have clicked off of all the rows. The function backgroundClicked() actually does nothing on my side. Is there something I’m forgetting? And a note for Jules, why does backgroundClicked() work on double clicks?

Basically what I want to do is when a user has a row selected and they click on some blank space, I want all rows to deselect.

Please assist.


#2

Go into the code in juce_ListBox.cpp, and search for the bit of code that actually calls backgroundClicked(). Put in a breakpoint, debug it, and trace into the call, to see why it’s not hitting your code. Normally when you trace through like this, the reason why it’s failing becomes blindingly obvious.


#3

Placed a breakpoint in this function

void mouseUp (const MouseEvent&) { if (owner.getModel() != 0) owner.getModel()->backgroundClicked(); }

Yet it actually doesn’t get called whatsoever.


#4

Then you must be clicking on one of the rows. Are some of your rows blank?


#5

I’m actually trying to click on the space at the end of the rows where there is nothing.


#6

ok, there’s something not working there. I’ll sort it out, but you could just use the ListBox’s mouseUp callback to catch the event in the meantime.


#7