mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Context Menu: UWP
This commit is contained in:
parent
ed46f5985c
commit
ed601bcbad
4 changed files with 46 additions and 7 deletions
|
@ -235,9 +235,9 @@ void ServoControl::OnSurfaceWheelChanged(
|
|||
void ServoControl::OnSurfaceResized(IInspectable const &,
|
||||
SizeChangedEventArgs const &e) {
|
||||
auto size = e.NewSize();
|
||||
auto w = size.Width * mDPI;
|
||||
auto h = size.Height * mDPI;
|
||||
RunOnGLThread([=] { mServo->SetSize(w, h); });
|
||||
auto w = (size.Width * mDPI);
|
||||
auto h = (size.Height * mDPI);
|
||||
RunOnGLThread([=] { mServo->SetSize((GLsizei)w, (GLsizei)h); });
|
||||
}
|
||||
|
||||
void ServoControl::GoBack() {
|
||||
|
@ -437,7 +437,7 @@ void ServoControl::OnServoAnimatingChanged(bool animating) {
|
|||
WakeConditionVariable(&mGLCondVar);
|
||||
}
|
||||
|
||||
void ServoControl::OnServoIMEStateChanged(bool aShow) {
|
||||
void ServoControl::OnServoIMEStateChanged(bool) {
|
||||
// FIXME:
|
||||
// https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-implementingtextandtextrange
|
||||
}
|
||||
|
@ -574,6 +574,30 @@ void ServoControl::OnServoDevtoolsStarted(bool success,
|
|||
ToastNotificationManager::CreateToastNotifier().Show(toast);
|
||||
}
|
||||
|
||||
void ServoControl::OnServoShowContextMenu(std::vector<winrt::hstring> items) {
|
||||
RunOnUIThread([=] {
|
||||
MessageDialog msg{L"Menu"};
|
||||
for (auto i = 0; i < items.size(); i++) {
|
||||
UICommand cmd{items[i], [=](auto) {
|
||||
RunOnGLThread([=] {
|
||||
mServo->ContextMenuClosed(
|
||||
Servo::ContextMenuResult::Selected, i);
|
||||
});
|
||||
}};
|
||||
msg.Commands().Append(cmd);
|
||||
}
|
||||
UICommand cancel{L"Cancel", [=](auto) {
|
||||
RunOnGLThread([=] {
|
||||
mServo->ContextMenuClosed(
|
||||
Servo::ContextMenuResult::Dismissed_, 0);
|
||||
});
|
||||
}};
|
||||
msg.Commands().Append(cancel);
|
||||
msg.CancelCommandIndex((uint32_t)items.size());
|
||||
msg.ShowAsync();
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) {
|
||||
Dispatcher().RunAsync(CoreDispatcherPriority::High, cb);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue