summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-12 12:21:50 -0400
committerPietro Gagliardi <[email protected]>2014-03-12 12:21:50 -0400
commit46c992f1dca9a76116e2ce3d07f97114bae331bb (patch)
tree913212f3fc1ceb3d2c47de9518d134e9b5f1f5ef
parentdd577010caeb3530a91565c933e75e52a5ed9b50 (diff)
Made message boxes run on uitask on Windows; adjusted some related TODOs.
-rw-r--r--dialog_windows.go24
-rw-r--r--todo.md4
2 files changed, 17 insertions, 11 deletions
diff --git a/dialog_windows.go b/dialog_windows.go
index 21beee0..29124a2 100644
--- a/dialog_windows.go
+++ b/dialog_windows.go
@@ -79,15 +79,23 @@ var (
func _msgBox(primarytext string, secondarytext string, uType uint32) (result int) {
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa511267.aspx says "Use task dialogs whenever appropriate to achieve a consistent look and layout. Task dialogs require Windows Vista® or later, so they aren't suitable for earlier versions of Windows. If you must use a message box, separate the main instruction from the supplemental instruction with two line breaks."
text := primarytext + "\n\n" + secondarytext
- r1, _, err := _messageBox.Call(
- uintptr(_NULL),
- uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
- uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(os.Args[0]))),
- uintptr(uType))
- if r1 == 0 { // failure
- panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", err, uType, os.Args[0], text))
+ ret := make(chan uiret)
+ defer close(ret)
+ uitask <- &uimsg{
+ call: _messageBox,
+ p: []uintptr{
+ uintptr(_NULL),
+ uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
+ uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(os.Args[0]))),
+ uintptr(uType),
+ },
+ ret: ret,
}
- return int(r1)
+ r := <-ret
+ if r.ret == 0 { // failure
+ panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", r.err, uType, os.Args[0], text))
+ }
+ return int(r.ret)
}
func msgBox(primarytext string, secondarytext string) {
diff --git a/todo.md b/todo.md
index 5f7a2bb..cd48250 100644
--- a/todo.md
+++ b/todo.md
@@ -16,8 +16,6 @@ so I don't forget:
- Combobox/Listbox.Select (with Listbox.Select allowing bulk)
- Checkbox.Check or Checkbox.SetChecked
- Listbox.SelectAll
-- make the Windows implementation of message boxes run on uitask
- - ensure MsgBoxError can run if initialization failed if things change ever
- should Labels be selectable?
- should message box text be selectable on all platforms or only on those that make it the default?
- Listbox/Combobox.Index(n)
@@ -25,7 +23,7 @@ so I don't forget:
- change sysData.make() so it does not take the initial window text as an argument and instead have the respective Control/Window.make() call sysData.setText() expressly; this would allow me to remove the "no such concept of text" checks from the GTK+ and Mac OS X backends
important things:
-- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one
+- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one (which would be desirable, maybe (would violate Windows HIG?))
- figure out where to auto-place windows in Cocoa (also window coordinates are still not flipped properly so (0,0) on screen is the bottom-left)
- also provide a method to center windows; Cocoa provides one for us but
- I think Cocoa NSButton text is not vertically aligned properly...?