Fixed Listboxes on Mac OS X having an initial selection.
This commit is contained in:
parent
274fa0c292
commit
d4c79539af
|
@ -148,6 +148,8 @@ func (l *Listbox) make(window *sysData) (err error) {
|
||||||
for _, s := range l.initItems {
|
for _, s := range l.initItems {
|
||||||
l.sysData.append(s)
|
l.sysData.append(s)
|
||||||
}
|
}
|
||||||
|
// some platforms automatically select an item; undo that
|
||||||
|
l.sysData.selectIndices(nil)
|
||||||
l.created = true
|
l.created = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,7 @@ var (
|
||||||
_selectedRowIndexes = sel_getUid("selectedRowIndexes")
|
_selectedRowIndexes = sel_getUid("selectedRowIndexes")
|
||||||
_count = sel_getUid("count")
|
_count = sel_getUid("count")
|
||||||
_numberOfRows = sel_getUid("numberOfRows")
|
_numberOfRows = sel_getUid("numberOfRows")
|
||||||
|
_deselectAll = sel_getUid("deselectAll:")
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeListbox(parentWindow C.id, alternate bool) C.id {
|
func makeListbox(parentWindow C.id, alternate bool) C.id {
|
||||||
|
@ -315,3 +316,12 @@ func deleteListbox(listbox C.id, index int) {
|
||||||
func listboxLen(listbox C.id) int {
|
func listboxLen(listbox C.id) int {
|
||||||
return int(C.objc_msgSend_intret_noargs(listboxInScrollView(listbox), _numberOfRows))
|
return int(C.objc_msgSend_intret_noargs(listboxInScrollView(listbox), _numberOfRows))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func selectListboxIndices(id C.id, indices []int) {
|
||||||
|
listbox := listboxInScrollView(id)
|
||||||
|
if len(indices) == 0 {
|
||||||
|
C.objc_msgSend_id(listbox, _deselectAll, listbox)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
panic("selectListboxIndices() > 0 not yet implemented (TODO)")
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ var _xSysData interface {
|
||||||
len() int
|
len() int
|
||||||
setAreaSize(int, int)
|
setAreaSize(int, int)
|
||||||
selectIndex(int)
|
selectIndex(int)
|
||||||
|
selectIndices([]int)
|
||||||
} = &sysData{} // this line will error if there's an inconsistency
|
} = &sysData{} // this line will error if there's an inconsistency
|
||||||
|
|
||||||
// signal sends the event signal. This raise is done asynchronously to avoid deadlocking the UI task.
|
// signal sends the event signal. This raise is done asynchronously to avoid deadlocking the UI task.
|
||||||
|
|
|
@ -34,6 +34,7 @@ type classData struct {
|
||||||
delete func(id C.id, index int)
|
delete func(id C.id, index int)
|
||||||
len func(id C.id) int
|
len func(id C.id) int
|
||||||
selectIndex func(id C.id, index int, alternate bool)
|
selectIndex func(id C.id, index int, alternate bool)
|
||||||
|
selectIndices func(id C.id, indices []int)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -304,6 +305,7 @@ var classTypes = [nctypes]*classData{
|
||||||
selTexts: selectedListboxTexts,
|
selTexts: selectedListboxTexts,
|
||||||
delete: deleteListbox,
|
delete: deleteListbox,
|
||||||
len: listboxLen,
|
len: listboxLen,
|
||||||
|
selectIndices: selectListboxIndices,
|
||||||
},
|
},
|
||||||
c_progressbar: &classData{
|
c_progressbar: &classData{
|
||||||
make: func(parentWindow C.id, alternate bool) C.id {
|
make: func(parentWindow C.id, alternate bool) C.id {
|
||||||
|
@ -571,3 +573,13 @@ func (s *sysData) selectIndex(index int) {
|
||||||
}
|
}
|
||||||
<-ret
|
<-ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *sysData) selectIndices(indices []int) {
|
||||||
|
ret := make(chan struct{})
|
||||||
|
defer close(ret)
|
||||||
|
uitask <- func() {
|
||||||
|
classTypes[s.ctype].selectIndices(s.id, indices)
|
||||||
|
ret <- struct{}{}
|
||||||
|
}
|
||||||
|
<-ret
|
||||||
|
}
|
||||||
|
|
|
@ -363,3 +363,7 @@ func (s *sysData) setAreaSize(width int, height int) {
|
||||||
func (s *sysData) selectIndex(index int) {
|
func (s *sysData) selectIndex(index int) {
|
||||||
// TODO not yet implemented on Unix (added for Mac only right now)
|
// TODO not yet implemented on Unix (added for Mac only right now)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *sysData) selectIndices(indices []int) {
|
||||||
|
// TODO not yet implemented on Windows (added for Mac only right now)
|
||||||
|
}
|
||||||
|
|
|
@ -645,3 +645,7 @@ func (s *sysData) setAreaSize(width int, height int) {
|
||||||
func (s *sysData) selectIndex(index int) {
|
func (s *sysData) selectIndex(index int) {
|
||||||
// TODO not yet implemented on Windows (added for Mac only right now)
|
// TODO not yet implemented on Windows (added for Mac only right now)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *sysData) selectIndices(indices []int) {
|
||||||
|
// TODO not yet implemented on Windows (added for Mac only right now)
|
||||||
|
}
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -1,5 +1,4 @@
|
||||||
important things:
|
important things:
|
||||||
- NSTableViews start out with an initial selection (which is against our docs)
|
|
||||||
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
|
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
|
||||||
- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges
|
- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges
|
||||||
- LineEdit heights on Windows seem too big; either that or LineEdit, Button, and Label text is not vertically centered properly
|
- LineEdit heights on Windows seem too big; either that or LineEdit, Button, and Label text is not vertically centered properly
|
||||||
|
|
Loading…
Reference in New Issue