the problem i am facing is, i have wrote a small function that highlights cells on hover... it works GREAT unless the cell spans multiple columns, then the spanned cells are not highlighted if hovering in the spanned cell area (past the first cell in the span).
the way i am doing this is as follows:
Code: Select all
my $last_col;
my $last_row;
my $id = $grid->GetGridWindow();
EVT_MOTION( $id, sub { onmove( $_[1], $grid, $grid2 ) } );
sub onmove {
my ( $event, $grid, $grid2 ) = @_;
my ($coords) = $event->GetPosition();
my ( $x, $y ) = $grid->CalcUnscrolledPosition( $coords->x, $coords->y );
my $col_pos = $grid->XToCol($x);
my $row_pos = $grid->YToRow($y);
#highlight cell on hover!
if ( $col_pos != $last_col or $row_pos != $last_row ) {
my $last_label = $grid2->GetCellValue( 0, $last_col ) if defined($last_col);
$last_label =~ /(\d{2})\/(\d{2})\/(\d{4})\s(\d{2}):(\d{2})/;
$grid->SetCellBackgroundColour( $last_row, $col_label_lookup{"$3$1$2$4$5"}, Wx::Colour->newRGB( 50, 50, 50 )) if defined($last_row);
$last_col = $col_pos;
$last_row = $row_pos;
my $label = $grid2->GetCellValue( 0, $col_pos );
$label =~ /(\d{2})\/(\d{2})\/(\d{4})\s(\d{2}):(\d{2})/;
$grid->SetCellBackgroundColour( $row_pos, $col_label_lookup{"$3$1$2$4$5"}, Wx::Colour->newRGB( 220, 220, 220 ));
$grid->Refresh;
}
}
https://imgur.com/a/Ny8myaw - hovering first cell in span
https://imgur.com/a/yJAXPGK - hovering past the first cell in the cell span
i did notice that if the cell is spanned, the built in functions of WxGrid are able to tell if it is spanned... if i select a cell thats spanned it outlines the whole spanned cell. so i need to figure out, hopefully with a little help, how wxgrid is managing to know if that cell is spanned and clone that behaviour.
the lib i am working with does not have GetCellSize built in. when i try to use this function i get an error "GetCellSize not found in Wx::Grid", but somehow the built in functions of WxGrid are able to tell because when i click a cell (in original cell or spanned from original cell), it outlines the whole spanned cell.
EDITED: updated description of the problem and added pictures which hopefully help describe my problem.