Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6818703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:12:42+00:00 2026-05-26T21:12:42+00:00

I have a strange issue: there is a SectionPart with composite, which is create

  • 0

I have a strange issue: there is a SectionPart with composite, which is create from FormToolkit#createComposite(getSection()). Composite contains some number of widgets, which are positioned vertically one under other (as in a usual form). When the cursor is inside some widget, let’s say input filed and I am clicking right between two fields on empty space, then focus automatically jumps to the first field in this composite.

I’ve tried to set SWT.NO_FOCUS style bit to the first widget in the form (usually it is a TableComboViewer) but it didn’t helped (it seems, that this bit is not set on TableCombo, which is inside TableComboViewer).

So, have anybody faced something similar, or are there any workarounds for this problem or any clues what could it be?

Upd1: setting NO_FOCUS style helps for non TableComboViewer widgets (in this case they are not receiving focus). In case of TableComboViewer TableCombo widget contains Text widget, which receives focus, but even, if I add NO_FOCUS bit, it is not applied to Text style. I’ve checked source of TableCombo and there is a method checkStyle, which does following:

private static int checkStyle (int style) {
 int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
 return SWT.NO_FOCUS | (style & mask);
}

I am not actually sure what it does, cause I am not really good in bitwise operation, but seems, that this is the problem, why I can’t set NO_FOCUS flag.

I don’t understand though, why when I am clicking on Composite, it tries to set foxus on it’s children, can I somehow suppress this?

Upd2: The reason is probably found, it is said, that:

When the view is activated, focus is transferred to the form, which passes it to the first control capable of accepting focus, our link in this case.

And it seems, that it is not possible to forbid this.

Thanks in advance,
AlexG

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:12:43+00:00Added an answer on May 26, 2026 at 9:12 pm

    You problem lies in Composite.setFocus().. have a look at this:

    public boolean setFocus () {
        checkWidget ();
        Control [] children = _getChildren ();
        for (int i= 0; i < children.length; i++) {
            if (children [i].setFocus ()) return true;
        }
        return super.setFocus ();
    } 
    

    As you can see, this will try to set the focus on the first control in the composite that will allow for the focus…

    [EDIT – the following is added to clarify…]

    The above method would not be a problem if it wasn’t for the MouseListener that is installed on all Composites in FormToolkit.adapt(Composite composite):

        public void adapt(Composite composite) {
            composite.setBackground(colors.getBackground());
            composite.addMouseListener(new MouseAdapter() {
                public void mouseDown(MouseEvent e) {
                    ((Control) e.widget).setFocus();
                }
            });
            if (composite.getParent() != null)
                composite.setMenu(composite.getParent().getMenu());
        }
    

    I have solved this problem on a number of occasions by having my own FormToolkit.adapt(Composite composite) in a sub-class that does the right thing – I just exchange setFocus() with forceFocus(). Though that can occasionally give you other problems…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange issue from a client in that our code, which they
I have a strange issue with Hibernate 3.5 which I hope some one can
I have this strange issue with some third party DLL's. The third party provider
I'm having a strange issue with some @font-face text where there is some strange
I have a strange issue with bluetooth socket. If I create socket and later
I have encountered strange issue. From Activity onStart() I request Bluetooth activation and 120s
Having a strange issue in IE7. In a number of spots, I have a
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
I have this strange issue with my web app. You see, I'm using jQuery
I have a strange issue (at least for me :)) with the MySQL's locking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.