extended display for an ipad is not clickable with a mouse that i connect to the ipad

28 Views Asked by At

I connect a mirroring screen and mouse to an ipad, in my application i add some code to display button, text on this second screen but the problem is i can't access to this element of the second screen with the mouse i can only access to the screen of the ipad with mouse,

      private func screenDidConnect(_ screen: UIScreen) {
    let window = UIWindow(frame: screen.bounds)

    window.windowScene = UIApplication.shared.connectedScenes
        .first { ($0 as? UIWindowScene)?.screen == screen }
        as? UIWindowScene

    let view = ExternalView()
        .environmentObject(externalDisplayContent)
    let controller = UIHostingController(rootView: view)
    window.rootViewController = controller
    window.isHidden = false
    additionalWindows.append(window)
    externalDisplayContent.isShowingOnExternalDisplay = true
}

private func screenDidDisconnect(_ screen: UIScreen) {
    additionalWindows.removeAll { $0.screen == screen }
    externalDisplayContent.isShowingOnExternalDisplay = false
}

My class ExternalDisplay :

struct ExternalView: View {

@EnvironmentObject var externalDisplayContent: ExternalDisplayContent

var body: some View {
    Text(externalDisplayContent.string)
    Button("click on me", action: {
        print("top")
    })
}

}

How can add Ui element to second screen and access to them with mouse please ?

0

There are 0 best solutions below