How to deselect text in Combobox? (Calc, Basic)

Creating a macro - Writing a Script - Using the API

How to deselect text in Combobox? (Calc, Basic)

Postby sevalav » Sat Dec 01, 2012 9:04 am

Hello,
I have some dialog in Calc, and combobox on this dialog. How to deselect text in combobox? When I click on dropdown list, selected item will be appear in comboboxs "screen". This item is whole in blue colored background, because it is selected. This is problem to me, because this item and other items on dropdown list are now case sensitive to my touch mouse "roller" on my lap top, and without my knowledge I can change seleceted item. Please a little help.
Apache OpenOffice 4.1.0, Win
sevalav
 
Posts: 91
Joined: Mon Apr 16, 2012 12:37 am

Re: How to deselect text in Combobox? (Calc, Basic)

Postby RPG » Sat Dec 01, 2012 12:16 pm

Hello

Maybe you can set a property of the combobox. There is a property hide Selection. Also control^Home seems to work.

Romke
LibreOffice 6.1.5.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2159
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: How to deselect text in Combobox? (Calc, Basic)

Postby B Marcelly » Sat Dec 01, 2012 2:47 pm

Are you sure you need a ComboBox ?
A Combobox is useful only when you need the facility to enter something else than one of the list items.
If you only need to select one of the items of the list, use a ListBox.

How to unselect all items at opening of the dialog :
  • With a ComboBox : in the IDE, properties, tab "General", property Text : clear this field.
  • With a ListBox : in the IDE, properties, tab "General", property Selection : clear this field.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
B Marcelly
Volunteer
 
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: How to deselect text in Combobox? (Calc, Basic)

Postby sevalav » Sun Dec 02, 2012 12:12 am

Thanks for your replies. I tried to implement suggestions but they do not solved my problems. As I can see, to stopping roller of mause to acting as I described in first post, I must implement some code for mouse event, what is... well, maybe little difficult for me. Second, because I have search results in other textfields based from text in combobox, it is much easier to me to put command .setFocus() in next field in the end of code which serve for searching. When focus is out of combobx the roller could not make a problems. I think this is satisfactory solution for me.
But I still have this question: how to select/deselect text in combobox with code (basic)?
Apache OpenOffice 4.1.0, Win
sevalav
 
Posts: 91
Joined: Mon Apr 16, 2012 12:37 am

Re: How to deselect text in Combobox? (Calc, Basic)

Postby Tshep » Tue Jun 26, 2018 5:24 am

I have the same problem. The code that I expect to do this would be
Code: Select all   Expand viewCollapse view
listbox.selectItemPos(-1, true)
, but running this does nothing. Interestingly, if you have a listbox with nothing selected and interrogate the property selectItemPos, it returns -1, which implies that
Code: Select all   Expand viewCollapse view
selectItemPos(-1,true)
should work. I have also tried
Code: Select all   Expand viewCollapse view
selectItem("")
which also just does nothing. My suspicion is that this is an oversight on the part of the developers. Certainly in VBA selecting a list position of -1 does the trick.
Openoffice 4.1.5 on Windows 10
Tshep
 
Posts: 3
Joined: Wed Jan 31, 2018 5:15 am

Re: How to deselect text in Combobox? (Calc, Basic)

Postby JeJe » Tue Jun 26, 2018 6:41 am

Tshep - have you tried setting the focus to another control? It could be a control that doesn't do anything and is outside the visible area of the dialog so hidden.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 429
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to deselect text in Combobox? (Calc, Basic)

Postby Zizi64 » Tue Jun 26, 2018 7:46 am

Tshep, ara you using one of the existing object inspection tools (Xray, MRI)? You can display all of the available properties and methods (and others) by usage of these tools.

Please upload your ODF type sample file here with the embedded macro routine what you tried to create.
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.5 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.1 and AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7770
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to deselect text in Combobox? (Calc, Basic)

Postby Tshep » Sun Jul 08, 2018 5:10 pm

Hello Tibor, sorry to have been away so long. I don't use xray or MRI - I've got my own routine that I use to inspect properties and methods. My file is too long to upload, but here's what you can do to replicate the problem. Create a dialog, drop a listbox and button on it. Add a few entries to the listbox list (apples, oranges, apricots, bananas etc). Set the button to run a macro when clicked and add these lines to the macro (say you called it "test"):
sub test(e as event)
'see what itemPos is with no selection at startup, then with an item selected
msgbox (e.Source.Context.getControl("ListBox1").selectedItemPos)
e.Source.Context.getControl("ListBox1").selectItemPos(-1,true)
end sub
What you will see is that at startup, no items selected, itemPos is -1. Go ahead and select an item. You will see it's position as selected. Click the button. Nothing happens. The item remains selected, even if you move the focus to any other control on the dialog. In fact, you can do nothing at all to un-select an item in the box short of restarting the dialog. Logically, setting itemPos to -1 should do this.
- Tshep
Openoffice 4.1.5 on Windows 10
Tshep
 
Posts: 3
Joined: Wed Jan 31, 2018 5:15 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests