OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

ListBox Fever: makevisible

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
JamesBittner
General User
General User


Joined: 26 Jan 2004
Posts: 6
Location: Fort Wayne, Indiana, USA

PostPosted: Tue Jan 27, 2004 1:11 pm    Post subject: ListBox Fever: makevisible Reply with quote

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
View user's profile Send private message AIM Address
Tomasz Zen Napierala
Newbie
Newbie


Joined: 31 Mar 2004
Posts: 4
Location: Nowy Tomysl / Poznan, Poland

PostPosted: Wed Mar 31, 2004 1:51 pm    Post subject: Reply with quote

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 Sad

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
View user's profile Send private message Visit poster's website
Tomasz Zen Napierala
Newbie
Newbie


Joined: 31 Mar 2004
Posts: 4
Location: Nowy Tomysl / Poznan, Poland

PostPosted: Wed Mar 31, 2004 2:14 pm    Post subject: Reply with quote

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 Wink
_________________
Tomasz Zen Napierala
MaroonPoint Polska
comfortable hosting services and more...
Back to top
View user's profile Send private message Visit poster's website
dfrench
Moderator
Moderator


Joined: 03 Mar 2003
Posts: 1605
Location: Wellington, New Zealand

PostPosted: Wed Mar 31, 2004 2:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group