Skip to content

Commit

Permalink
Merge pull request #1238 from Nivaturimika/fxflagbtn
Browse files Browse the repository at this point in the history
fix flag button absorbing click events on the diplomatic message topbar stuff
  • Loading branch information
schombert authored Apr 7, 2024
2 parents 2cee90e + dec89f2 commit 39cbcdc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/gui/gui_diplomacy_request_topbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,20 @@ class diplomatic_message_topbar_button : public button_element_base {

void button_action(sys::state& state) noexcept override;
};

class diplomatic_message_topbar_flag_button : public flag_button {
public:
void button_action(sys::state& state) noexcept override;
};
class diplomatic_message_topbar_entry_window : public listbox_row_element_base<diplomatic_message::message> {
public:
diplomatic_message_topbar_button* btn = nullptr;
std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override {
if(name == "diplomessageicon_button") {
return make_element_by_type<diplomatic_message_topbar_button>(state, id);
auto ptr = make_element_by_type<diplomatic_message_topbar_button>(state, id);
btn = ptr.get();
return ptr;
} else if(name == "flag") {
return make_element_by_type<flag_button>(state, id);
return make_element_by_type<diplomatic_message_topbar_flag_button>(state, id);
} else if(name == "messageicon_bg_overlay") {
return make_element_by_type<image_element_base>(state, id);
} else {
Expand Down Expand Up @@ -151,4 +157,12 @@ void diplomatic_message_topbar_button::button_action(sys::state& state) noexcept
dmtl->impl_on_update(state);
}

void diplomatic_message_topbar_flag_button::button_action(sys::state& state) noexcept {
if(parent) {
auto win = static_cast<diplomatic_message_topbar_entry_window*>(parent);
if(win->btn)
win->btn->button_action(state);
}
}

}

0 comments on commit 39cbcdc

Please sign in to comment.