last day (14 days later) » 

1:06 PM
1
A: SWT Table without selection

BazYou can force the focus on another Widget that's not your Table. By doing that, you'll loose the dotted line (which represents the focus). Here is an example: public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shel...

 
Thanks. I created an invisible button invisibleButton = new Button(table, SWT.NONE); invisibleButton.setVisible(false); and redirect the focus to it if needed invisibleButton.setFocus(); invisibleButton.forceFocus(); (it's slightly more complicated than your example because one of the columns is editable). But why does the style option SWT.NO_FOCUS not do what it is supposed to do?
 
Baz
@DanyloEsterman A lot of the style bits are just hints. The OS might respect them or it might now.
 
I've got another small question. Do I really need to reset all fields of the event object?
 
Baz
@DanyloEsterman No, event.doit = false should be sufficient.
@DanyloEsterman Just tested, you don't even need event.doit = false, cause it's not actually preventing the event anyway.
 
Yep I wondered already if it makes a difference. The SelectionEvent is fired after the selection was made, isn't it?
 
Baz
1:06 PM
@DanyloEsterman Indeed it is.
@DanyloEsterman You can even use this rather than deselecting all elements manually. Looks like a cleaner solution. You'll still need to loose the focus though.
 
Switched to the suggested solution which works for the selection as well. Using the EraseItem event appears mystical to me though. And the following expression seems not quite clear for me too: event.detail &= ~SWT.SELECTED; I'd rather use event.detail ^= SWT.SELECTED; if I wanted to keep the other event details and if there's any.
 
Baz
@DanyloEsterman Looking at the code of Shell for example you'll see &= ~SOMETHING all the time. XOR doesn't seem right here.
 
If we have 2 details in an event: SWT.SELECTED which is 2 and some other which is let's say 8, then event.detail would look like this 1010. I want to set SWT.SELECTED to 0, right? 1010 XOR 0010 = 1000. Using an AND with the negative of SWT.SELECTED will clear the whole thing: 1010 AND 0000 = 0000. Am I overseeing something?
 
Baz
@DanyloEsterman You just want to remove SWT.SELECTED from the event.detail, if it's position is 1 the &= ~ will set it to 0, if it's 0, it'll still be 0.
 
Since we check if SWT.SELECTED is set, XOR will set it to zero as well. But with the big difference: it won't set the other flags to zero.
 
Baz
1:09 PM
Hi
 
Baz
Ok, from what I know the bits that can be used together use distinct positions, i.e. they don't interfere with each other
Otherwise if you use 111 and 010 how would you know if 010 was actually part of your style?
 
Yes, well to see if 010 is part of 111 I do 010 and 111
The result is 010, i.e. not equal to zero, that's why 010 is the part of 111
 
Baz
the styles are created by using OR ("|"). If you want to use both 111 and 010 you'd do 111 | 010 = 111. If you afterwards want to check if 010 was actually used, you're boned
 
Well I wouldn't actually make sense to define a style with more than 1 bit set. More specifically I would define 111 as a mixed style where 100, 010 and 001 are used.
 
Baz
1:14 PM
sure it does make sense. It's used all the time. See documentation of Shell:help.eclipse.org/indigo/…
SHELL_TRIM
the result of combining the constants which are required to produce a typical application top level shell: (that is, CLOSE | TITLE | MIN | MAX | RESIZE)
 
Thus if you want to use both 111 and 010 it would be enough just to use 111 as it already contains 010
 
Baz
that's why they use distinct positions, so that combining is possible
 
Yeah well, this is the same what I already said
Styles mixed of different style flags
 
Baz
But if they're distinct using &= ~ is fine
 
I disagree
If you use AND you will set the rest to 0
 
Baz
1:16 PM
well, then argue with the SWT developers. They use it all the time
 
Oh god...
I see my mistake
Using an AND with the negative of SWT.SELECTED will clear the whole thing: 1010 AND 0000 = 0000
Negative of SWT.SELECTED would be 1101
Its time to drink beer i think :D
 
Baz
good choice ;)
 
Nevertheless, XOR would be correct choice as well :P
For this purpose at leas
t
 
Baz
but it's always good to stick to the conventions of the framework you're using
 
Good point
 
Baz
1:24 PM
glad that's sorted out. good luck with your application
 
Thanks for helping
stackoverflow ftw!
 
Baz
no problem, that's what i'm here for
 
I'll probably bother you again tomorrow :D
 
Baz
heh, please do. i'm always glad if i can help
 
But for now it is the end of the work day
 
Baz
1:25 PM
well then enjoy the rest of your day
 
you too
cya and good luck
 
Baz
cheers
 

last day (14 days later) »