Highlight problem for TableListBox's TableheaderComponent


#1

Hello All,

If MouseIntercept is not disabled on TableListBox, TableHeaderComponent’s header which are “first” and “second” in following case were highlighted with some colour when mouse comes to it.
But when MouseIntercept is disabled on TableListBox, Only component’s mouseEvents are used. And using MouseMove when mouseEvent is forwarded to tableListBox->getHeader().mouseMove(e); No effect appears like it highlight with colour.

What can be the problem here? please suggest what can solve and get highlight back on the headed with tableListBox->setinterceptMouseClicks(false, false); on the TableListBox.

class a : component, TableListBoxModel { a() { TableListBox * tableListBox = new TableListBox("table", this); tableListBox->getHeader().addColumn("first", 1, 10, 10, 1000, TableHeaderComponent::notResizable); tableListBox->getHeader().addColumn("Second", 2, 10, 10, 1000, TableHeaderComponent::notResizable); tableListBox->setinterceptMouseClicks(false, false); } mouseMove(const MouseEvents & e) { if(tableListBox->getHeader().getBounds().contains(e.x, e.y)) { table->getHeader().mouseMove(e); } } };

Thanks buddies.


#2
  1. Why do you disable interception and yet try to send back the event to the child you’ve explicitely told not to intercept the event ?
    (Said differently, aren’t you trying to fix something the bad way ?)

  2. Even if you have good reason to disable own component mouse event handling, you have to convert the mouse event to the component’s local coordinate in order for it to be able to understand this. Please have a look to MouseEvent::getEventRelativeTo()


#3

Hi X-Ryl,

I understand that, we should not disable mouseIntercept. But It is required may be.

I need to create dragging image to send into startDragAndDrop, So it has to use mouseDrag of component, and create image manually to show while dragging.

I have seen that into TableHeaderComponent’s source, updateColumnUnderMouse(private method) is called while it get MouseMove, MouseEnter, MouseExit events… So i guess header should highlight when it get’s events related to that. (I tried sending event related to e.eventRelativeTo(tableListBox->getHeader()), but that too not Hit ).


#4

Hello Jules,

can you please point out what could be possible problem for the above scenario ?

later I tried with drawTableHeaderColumn on defaultLookAndFeel, but that too not worked.

Thanks…


#5

Sorry, I’m really struggling to understand what you’re trying to do…? If you want to have some special mouse handling in your header component, then you need to create a custom header component, and not try to use the table component to do it, which will cause all sorts of problems.


#6

Hamm. Jules sorry if i explained it complexly.

But what i do is very basic.
when implemented tableListBoxModel and has two header columns. when mouse goes over it, they are highlighted with some different color.
But after setinterceptMouseClicks(false, false); for tableListBox which has two columns, do not get highlighted though i pass mouse events to tableListBox->getheader() … and still no highlight on that column header.


#7

Well no, of course they won’t get highlighted if you stop mouse-events going to that component.

And like x-ryl said in his reply earlier, you can’t just call naively call mouseMove like that and expect it to work. Calling any mouse event callback method directly is actually quite dangerous because components may expect to have all of their mouse callbacks called in the correct order - e.g. a component may assume that mouseEnter will always be called before mouseMove, so if you just call mouseMove() on its own, it may fail/crash. And it certainly won’t do what you’re expecting in this case.


#8

Hamm thank Jules for your answer.

Actually I need to make items of tableListBox get dragged with custom image,
The virtual method for tableListBoxModel getDragSourceDescription allow me to do it but not with custom image.

By startDragAndDrop method can let me do that, but it can be called from component’s mouseDrag, and as tableListbox is having all mouse attention, i don’t get mouseDrag for that component, that’s why tableListBox’s mouseInteraction were set to off.

Please tell me , if any other way i can use to create custom image while dragging row from tableListBox ? Thanks for your precise explanation.


#9

Put a component inside each cell of your table and let the user drag this component.
You don’t need to touch the table at all!


#10

Right X-Ryl

That is quite a nice way, i tried it and it works well, thanks.