diff --git a/playlet-lib/src/components/Dialog/DialogUtils.bs b/playlet-lib/src/components/Dialog/DialogUtils.bs
index 2be75f14..0f366413 100644
--- a/playlet-lib/src/components/Dialog/DialogUtils.bs
+++ b/playlet-lib/src/components/Dialog/DialogUtils.bs
@@ -49,6 +49,8 @@ namespace DialogUtils
m.top.getScene().dialog = dialog
+ dialog.focusDefaultButton = true
+
return dialog
end function
end namespace
diff --git a/playlet-lib/src/components/Dialog/TimedDialog.bs b/playlet-lib/src/components/Dialog/TimedDialog.bs
index 439ea49c..409d165f 100644
--- a/playlet-lib/src/components/Dialog/TimedDialog.bs
+++ b/playlet-lib/src/components/Dialog/TimedDialog.bs
@@ -1,4 +1,5 @@
import "DialogPalette.bs"
+import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
@@ -30,8 +31,20 @@ function OnStartCountdown()
m.currentCountDown = defaultActionTimeoutSeconds
m.timer.control = "start"
- FindContentComponent()
- WatchContentTranslation()
+ FindButtonComponent()
+end function
+
+function OnFocusDefaultButton() as void
+ FindButtonComponent()
+ if m.buttonComponents = invalid
+ return
+ end if
+ defaultButtonIndex = m.top.defaultButtonIndex
+ if m.buttonComponents.Count() <= defaultButtonIndex
+ return
+ end if
+ button = m.buttonComponents[defaultButtonIndex]
+ NodeSetFocus(button, true)
end function
function TimerUpdateButtons() as void
@@ -42,7 +55,6 @@ function TimerUpdateButtons() as void
return
end if
- FindButtonComponent()
SetDefaultButtonText(m.currentCountDown)
end function
@@ -53,7 +65,6 @@ end function
function OnDialogClosed()
CancelTimer()
- UnwatchContentTranslation()
end function
function onKeyEvent(key as string, press as boolean) as boolean
@@ -62,7 +73,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if
CancelTimer()
- UnwatchContentTranslation()
FindButtonComponent()
SetDefaultButtonText(0)
@@ -105,44 +115,3 @@ function FindButtonComponent() as void
end for
LogWarn("No buttons found in dialog")
end function
-
-function FindContentComponent() as void
- if m.contentComponent <> invalid
- return
- end if
-
- areas = m.top.getChildren(-1, 0)
- for each area in areas
- if area.subtype() = "StdDlgContentArea"
- if area.getChildCount() > 0
- m.contentComponent = area.getChild(0)
- end if
- return
- end if
- end for
- LogWarn("No content component found in dialog")
-end function
-
-function WatchContentTranslation() as void
- if m.contentComponent = invalid
- return
- end if
-
- m.contentComponent.observeFieldScoped("translation", FuncName(OnContentMoved))
-end function
-
-function UnwatchContentTranslation() as void
- if m.contentComponent = invalid
- return
- end if
-
- m.contentComponent.unobserveFieldScoped("translation")
- m.contentComponent = invalid
-end function
-
-function OnContentMoved()
- CancelTimer()
- UnwatchContentTranslation()
- FindButtonComponent()
- SetDefaultButtonText(0)
-end function
diff --git a/playlet-lib/src/components/Dialog/TimedDialog.xml b/playlet-lib/src/components/Dialog/TimedDialog.xml
index 8558528b..703cd7d1 100644
--- a/playlet-lib/src/components/Dialog/TimedDialog.xml
+++ b/playlet-lib/src/components/Dialog/TimedDialog.xml
@@ -6,5 +6,6 @@
+
\ No newline at end of file