Code: Select all
void MapTileWindow::OnClick(wxMouseEvent& evt)
{
function<void(wxMouseEvent&)> f = [this](wxMouseEvent& evt)
{
wxPoint p = evt.GetPosition();
for(MapTile& m : this->map_tiles_selection)
{
if((p.x >= m.GetBounds().x && p.x <= m.GetBounds().x + m.GetBounds().width) &&
(p.y >= m.GetBounds().y && p.y <= m.GetBounds().y + m.GetBounds().height))
{
if(mouseover_map_tile && mouseover_map_tile == &m){mouseover_map_tile = nullptr;}
active_map_tile = &m;
m.highlighted = 1;
wxString s = wxString::Format(L"Selected Tile: %s", m.GetTileName());
CallAfter([s, this](){active_map_tile_label->SetLabelText(s);});
CallAfter([this](){active_map_tile_label->Refresh();});
CallAfter([this](){Refresh();});
return;
}
else if(m.highlighted){m.highlighted = 0;}
else{m.highlighted = 0;}
}
CallAfter([this](){Refresh();});
wxString c = wxString::Format(L"maptileselect coords (%d, %d)", p.x, p.y);
if(!grandparent){CallAfter([this](){wxMessageBox(L"Invalid GrandParent Pointer", L"Error", wxICON_INFORMATION);});}
if(!grandparent->status_bar){CallAfter([this](){wxMessageBox(L"Invalid GrandParent StatusBar Pointer", L"Error",
wxICON_INFORMATION);});}
CallAfter([this, c](){grandparent->status_bar->SetStatusText(c, 0);});
};
thread t{f, ref(evt)};
t.detach();
return;
}
Hmm, after some testing I still have not discovered the cause of this issue. I at first believed the issue to be a multi-threading problem, but this is not the case. The only assumption I can make is that the cause of the problem might be a result of the wxStaticText object's parent being a parent of the window it is initialized in, MapTileWindow. However, the SetLabel() function works with no issue when supplying a string literal -- even constructing a wxString within the function works to reset the label.
Bah -- foolish me. The solution was not related to wxWidgets. It was the result of an incorrectly implemented copy constructor.