| View previous topic :: View next topic |
| Author |
Message |
JamesBittner General User

Joined: 26 Jan 2004 Posts: 6 Location: Fort Wayne, Indiana, USA
|
Posted: Tue Jan 27, 2004 1:11 pm Post subject: ListBox Fever: makevisible |
|
|
Me again.
Now that I can identify the listbox item I want to be displayed in my dropdown box I've tried this code snippet;
xDoc = ThisComponent
xForm = xDoc.DrawPage.Forms(0)
xCtl = xForm.getByName("ListBox")
xController = xDoc.CurrentController
xCtlView = xController.getControl(xCtl)
xCtlView.makeVisible(9)
xCtlView.SetFocus
For testing purposes I want to default to item 9 in my list and have that show up in my dropdown list box window.
The code executes ok, but I'm not getting the result I'm after. The SetFocus works as I would expect but the makeVisible isnt doing what I'm after.
Ok, what am I missing?
j.b. _________________ Know who your dealing with! |
|
| Back to top |
|
 |
Tomasz Zen Napierala Newbie

Joined: 31 Mar 2004 Posts: 4 Location: Nowy Tomysl / Poznan, Poland
|
Posted: Wed Mar 31, 2004 1:51 pm Post subject: |
|
|
I've got the same problem. I was trying makeVisible and selectItem (Pos, True) and had no effects. What is wrong?.
I found something in standard OO macros, but this function is trying to write to read-only property
Sub SelectListboxItem(oListbox as Object, iSelIndex as Integer)
Dim LocSelList(0) as Integer
If iSelIndex <> -1 Then
LocSelList(0) = iSelIndex
oListbox.SelectedItems() = LocSelList()
End If
End Sub _________________ Tomasz Zen Napierala
MaroonPoint Polska
comfortable hosting services and more... |
|
| Back to top |
|
 |
Tomasz Zen Napierala Newbie

Joined: 31 Mar 2004 Posts: 4 Location: Nowy Tomysl / Poznan, Poland
|
Posted: Wed Mar 31, 2004 2:14 pm Post subject: |
|
|
| Tomasz Zen Napierala wrote: | I've got the same problem. I was trying makeVisible and selectItem (Pos, True) and had no effects. What is wrong?.
|
I've got it! I was using oListBox.selectItem(Position, True) instedd of (Position, 1). It is strange, but for SO Basic, True is not True  _________________ Tomasz Zen Napierala
MaroonPoint Polska
comfortable hosting services and more... |
|
| Back to top |
|
 |
dfrench Moderator

Joined: 03 Mar 2003 Posts: 1605 Location: Wellington, New Zealand
|
Posted: Wed Mar 31, 2004 2:50 pm Post subject: |
|
|
James,
MakeVisible scrolls within the listbox (not a dropdown one) but doesn't do the selection.
The index values are from zero so line 9 is referenced by the value 8
| Code: | Sub Main
xDoc = ThisComponent
xForm = xDoc.DrawPage.Forms(0)
xCtl = xForm.getByName("ListBox")
xController = xDoc.CurrentController
xCtlView = xController.getControl(xCtl)
xctlview.SelectItemPos(9,true) ' make single selection (line 10)
xCtlView.makeVisible(9) 'makes the item at the specified position (line 10) visible by scrolling.
xCtlView.SetFocus 'sets the focus to the window
End Sub |
Tomasz
If you want to select within the macro code you have to work with the view of the control not the model. Have a look at the Basic Programmers Guide for StarOffice 7 Office Suite which covers the difference between model, view and shape aspects of a control.
| Code: | Sub Main
xDoc = ThisComponent
xForm = xDoc.DrawPage.Forms(0)
xCtl = xForm.getByName("ListBox")
xController = xDoc.CurrentController
xCtlView = xController.getControl(xCtl)
SelectListboxItem(xctlview,6)
End Sub
Sub SelectListboxItem(oListboxview as Object, iSelIndex as Integer)
If iSelIndex <> -1 Then
oListboxview.SelectItemPos(iSelIndex,true)
' this adds a selection to any existing selection(s)
end if
end sub | End Sub |
|
| Back to top |
|
 |
|