Skip to content

Commit

Permalink
Disable keyWindow workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
noppefoxwolf committed Jun 23, 2022
1 parent ebce4b2 commit cccb7fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Example.swiftpm/Source/UIKItExampleModule/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
DebugMenu.install(
windowScene: windowScene,
items: [
AlertDebugMenu(),
ViewControllerDebugItem<ColorViewController>(builder: { $0.init(color: .blue) }),
ClearCacheDebugItem(),
UserDefaultsResetDebugItem(),
Expand Down Expand Up @@ -70,3 +71,14 @@ class RootViewController: UIViewController {

override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge { .all }
}

struct AlertDebugMenu: DebugItem {
var debugItemTitle: String = "Alert"
var action: DebugItemAction = .didSelect { @MainActor controller in
let alert = UIAlertController(title: "Input Text", message: nil, preferredStyle: .alert)
alert.addTextField()
alert.addAction(.init(title: "OK", style: .default))
controller.present(alert, animated: true)
return .success()
}
}
9 changes: 5 additions & 4 deletions Sources/DebugMenu/View/InAppDebuggerWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public class InAppDebuggerWindow: UIWindow {

internal required init?(coder: NSCoder) { fatalError() }

public override func makeKey() {
// workaround: Make a new UIWindow without become key.
// https://stackoverflow.com/a/64758605/1131587
}
// deprecated: Keyboard input not working without responder chain.
// public override func makeKey() {
// // workaround: Make a new UIWindow without become key.
// // https://stackoverflow.com/a/64758605/1131587
// }

public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let view = super.hitTest(point, with: event)
Expand Down

0 comments on commit cccb7fc

Please sign in to comment.