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

accessing active control in Base

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


Joined: 06 Sep 2006
Posts: 14
Location: Ontario, Canada

PostPosted: Tue Oct 03, 2006 5:33 am    Post subject: accessing active control in Base Reply with quote

Hi everyone!

Does anybody know how to access the currently active control (textbox in my case) in Base?

Thanks
lm
Back to top
View user's profile Send private message Send e-mail
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Tue Oct 03, 2006 9:25 am    Post subject: Reply with quote

This a control on a form then?

Not in a dataview or queryview component right?

Not that I have an answer for this, but I might know another way of doing what you want - depending on what that is? As for finding the active control on a form, there must be someway...perhaps view the currentcontroller on the text document or using AWT toolkit.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lm
General User
General User


Joined: 06 Sep 2006
Posts: 14
Location: Ontario, Canada

PostPosted: Tue Oct 03, 2006 11:02 am    Post subject: Reply with quote

Yes, this is a control on a form. I'm building a database to keep track of work orders and packing slips, and I want to copy a value from one form (work order) to another (packing slip). I suppose I shouldn't really be doing this with macros, but I'm much more comfortable working with macros than with Base itself.

I'll keep searching the documentation myself, but any help is appreciated.

lm
Back to top
View user's profile Send private message Send e-mail
lm
General User
General User


Joined: 06 Sep 2006
Posts: 14
Location: Ontario, Canada

PostPosted: Thu Oct 05, 2006 8:05 am    Post subject: Reply with quote

I think getCurrentControl() is what I need, but I get errors with it. Anybody got some working code with this function?

lm
Back to top
View user's profile Send private message Send e-mail
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Thu Oct 05, 2006 8:42 am    Post subject: Reply with quote

you can get a control by its name, it that would help

EDIT-

This is what I mean,

I suppose you are opening both forms. If this is true then you have a variable, or should, to both data entry forms.

Using these variable you can access any control on either form, by name. So the act of transfering data is fairly simple.

Another thing that you can do is to use a hidden control on a form. Then lets say on your order form you have a button that opens your second form. Well, in the macro that does this you can copy the data into this hidden control, then in the second form you can use this hidden controls data for your purposes.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lm
General User
General User


Joined: 06 Sep 2006
Posts: 14
Location: Ontario, Canada

PostPosted: Fri Oct 06, 2006 8:02 am    Post subject: Reply with quote

I know how to access the controls on the form by name, but what I'm after is to find out which control on the open form has the focus when my macro is called.
Back to top
View user's profile Send private message Send e-mail
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Fri Oct 06, 2006 9:48 am    Post subject: Reply with quote

I have been trying to figure that out since reading your post. So far I am up against a wall, I will post the question to the mail list at dba@openoffice.org and see if one of the developers can help with this.

I saw your post regarding getCurrentControl which works for a XTabbController and have looked at the documentation regarding it - but so far that has proven to be a dead end also. There is an example of using the function in the code snippet section on the main OOo web site, but it is in a different context. I have not been able to convert that working code to work with a Base form.

When I hear from the developers as I am sure I will I will post the reply up here. EDIT - as I hope I will... Confused - END EDIT
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rocketman@JSC
Newbie
Newbie


Joined: 07 Oct 2006
Posts: 3
Location: Houston, TX

PostPosted: Sat Oct 07, 2006 1:30 pm    Post subject: Reply with quote

lm wrote:
I know how to access the controls on the form by name, but what I'm after is to find out which control on the open form has the focus when my macro is called.


Drew,

I'm also looking for a way to do this. Started by searching and found this thread with the same basic question. In my case, I may have many controls embedded in a writer document. It appears to me that the macros (subs) are kindof global in scope and not tied to any object. I want one macro that can do a job for many controls, but the macro needs to know which specific control called it thru the event bindings. Also the macro will not have a hard-coded name to look-up an object reference.

Can the controls event bound macro be called with an object reference? In this case I think the macro would be a function with argument of the object calling it. I guess there would need to be something like a thisControl object that would be passed in. Kind of like a "this" pointer in C++.

Thanks, Scott

p.s. I'm trying to get this working for OO and StarOffice. Ultimately I want to do requirement traceability thru multiple documents using these embedded controls. Should be pretty cool once it works.
Back to top
View user's profile Send private message
Rocketman@JSC
Newbie
Newbie


Joined: 07 Oct 2006
Posts: 3
Location: Houston, TX

PostPosted: Sat Oct 07, 2006 2:13 pm    Post subject: Nevermind! Reply with quote

Well I found out how. Many thanks to Andrew Pitonyak.

See section 10.3.2 of http://www.pitonyak.org/AndrewMacro.pdf

It works!!!! But if someone could explain how the macro knows what to put in as x--or is this like Python where the first arg is self?

Code:

Sub ButtonCall(x)
  Dim oButton ' Button that was used to call the handler.
  Dim oModel ' The model for the button.
  Dim oShape ' The underlying button shape.
  Dim i As Long ' Generic index variable.
  Dim bFound As Boolean ' True after find the matching shape.
  REM First, get the button used to call this routine.
  REM Save the button's model.
  oButton = x.Source
  oModel = oButton.getModel()
  REM Iterate through the controls
  i = ThisComponent.getDrawPage().getCount()
  bFound = False
  Do While (i > 0 AND NOT bFound)
    i = i - 1
    oShape = ThisComponent.getDrawPage().getByIndex(i)
    bFound = EqualUNOObjects(oShape.Control, oModel)
  Loop
  If bFound Then
    Print "The button is in cell " & oShape.getAnchor().Cell.CellName
  End If
End Sub
Back to top
View user's profile Send private message
lm
General User
General User


Joined: 06 Sep 2006
Posts: 14
Location: Ontario, Canada

PostPosted: Tue Oct 10, 2006 8:12 am    Post subject: Reply with quote

Scott,

I think what you are doing is not quite what I need to do. Your code accesses the button that was clicked to launch the macro, right? What I need is to access the textbox that had the focus BEFORE the button is clicked. Any thoughts on that ?

Thanks,
lm
Back to top
View user's profile Send private message Send e-mail
Rocketman@JSC
Newbie
Newbie


Joined: 07 Oct 2006
Posts: 3
Location: Houston, TX

PostPosted: Sat Oct 14, 2006 3:58 am    Post subject: Reply with quote

lm wrote:
What I need is to access the textbox that had the focus BEFORE the button is clicked. Any thoughts on that ?


Yea that sounds alot harder. Sorry can't help much with that one.
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