Skip to Content
author's profile photo Former Member
Former Member

Event trapping ....

Bit of a long one this , so hope you can bare with me ...

I have an addon which consists of a number of screens fired up from menus .. One of the screens is a UDO which , when i press cancel key , takes me back to main menu and i can select it again .. Another of the screens has just a matrix and a couple of buttons on it - one of which is a cancel button .. Now when i press the cancel button it takes me back to the main menu BUT it wont let me select and other menu items associated with my addon - standard SAP options are fine. Nothing happens on selection .. I looked at the events using event logger and I can see the Menu Event being selected but the screens never open .. I used B1DE to generate the listeners and in the form close button listener I have ..


  [B1Listener(BoEventTypes.et_CLICK, false)]

        public virtual void OnAfterClick(ItemEvent pVal) {
            bool ActionSuccess = pVal.ActionSuccess;
            Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
            Item item = form.Items.Item("btCancel");
            Button button = ((Button)(item.Specific));
            // ADD YOUR ACTION CODE HERE ...

            form.Close();
        }

I suspected that it maybe something to do with event filtering in my addon so I added following code at the top

of the constructor to see if it would work ..


    // ADD YOUR INITIALIZATION CODE HERE	...

            EventFilters filters = B1Connections.theAppl.GetFilter();

            //  Create list of events/types we are interested in  .. 

            EventFilter filter = filters.Add(BoEventTypes.et_KEY_DOWN);
            filter.AddEx("MyScreen");

            filter = filters.Add(BoEventTypes.et_PICKER_CLICKED);
            filter.AddEx("MyScreen");

            // filter = filters.Add(BoEventTypes.et_FORM_CLOSE);
            // filter.AddEx("MyScreen");

            B1Connections.theAppl.ItemEvent += new _IApplicationEvents_ItemEventEventHandler(theAppl_ItemEventHandler);
            
            B1Connections.theAppl.SetFilter(filters);

Note the comments around the FORM-CLOSE filter .. When I remove these and run addon in debug I get an error when connecting to SAP saying "Connection Failed : An attempt was made to reference a token which does not exist" .. If I leave the comments then the addon starts up BUT i have the previously mentioned error with selecting options from menus .. I thought that the FORM_CLOSE event would be handled by the same handler as I use for KEY_DOWN / PICKER_CLICKED - they seem to work fine if FORM_CLOSE commented out .. Also If I use filters in this way is it then my responsibility to explicitely define every event on every screen in my addon in which i am interested ? Finally is there any other way of registering a listener for a keypress on a form in B1DE ? I can't find anywhere where this event is exposed ..

I am on S2007 A P/L 15 .. Also I have stopped / restarted SAP and cleared temp directory and it made no difference .. I'm still pretty new to SAP but i'm finding developing for it a little frustrating .. Can anyone help ?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 05:11 AM

    Rob,

    it may sound weird but I wonder why you need to handle click of cancel button at all. I mean, if in screen painter or through code, the button is created with unique id 2, it will close the form itself on clicking. and you need not write form.close(). unless you want to wipe out some variables on the closing of the form.

    Regards,

    Binita Joshi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.