Fwd: TableView - listening to events on table headers
Pedro Duque Vieira
pedro.duquevieira at gmail.com
Wed Oct 24 08:22:22 PDT 2012
Hi Steve,
I will enter that Jira issue than...
Thanks, best regards,
On Wed, Oct 24, 2012 at 3:56 PM, <steve.x.northover at oracle.com> wrote:
> Hi Pedro,
>
> You can always use a filter to see every click that happens in a control:
>
> tableView.addEventFilter(**MouseEvent.MOUSE_PRESSED, new
> EventHandler() {
> public void handle(Event event) {
> System.out.println("Press " + event.getSource() + " " +
> event.getTarget());
>
> }
> });
>
> However, you then need to determine that the target was a table header
> node and that seems like reaching into the implementation. I would suggest
> that you stick with setGraphic() if this is working for you and enter a
> JIRA feature request for mouse and other event handlers for table column
> headers.
>
> Steve
>
>
> On 23/10/2012 8:03 PM, Pedro Duque Vieira wrote:
>
>> Somehow my email below didn't get any response so I'm sending it again..
>> ---------- Forwarded message ----------
>> From: Pedro Duque Vieira<pedro.duquevieira@**gmail.com<pedro.duquevieira at gmail.com>
>> >
>> Date: Tue, Oct 23, 2012 at 12:42 AM
>> Subject: TableView - listening to events on table headers
>> To: OpenJFX Mailing List<openjfx-dev at openjdk.java.**net<openjfx-dev at openjdk.java.net>
>> >
>>
>>
>> Hi,
>>
>> In my app I have to listen to mouse events on table headers, I've tried to
>> come up with a good solution to this but haven't found any. Posting in the
>> JavaFX OTN forums also did not bring any better solution.
>> As it is the only solution I see is replacing the headers via setGraphic
>> method of TableColumn and attaching listeners to what I pass in to the
>> setGraphic, even though I will end up replacing the TableColumn header
>> with
>> the same type of node as was previously present, so I end up calling
>> setGraphic only for the sake of being able to attach listeners. This looks
>> ugly.
>>
>> Is there any better solution for this?
>>
>> My use case is:
>> 1- user mouse clicks the a table header to select a column
>> 2- column gets selected.
>> 3- Selected column is visually highlighted.
>>
>> Thanks,
>>
>>
>>
--
Pedro Duque Vieira
More information about the openjfx-dev
mailing list