Issue 111176 - Selection change event of worksheet does not work well when the prompt a messagebox in the event
Summary: Selection change event of worksheet does not work well when the prompt a mess...
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: vba (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact: noel.power
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-27 07:50 UTC by lihuiibm
Modified: 2017-05-20 11:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Test sample for this issue (16.50 KB, text/plain)
2010-04-27 07:54 UTC, lihuiibm
no flags Details
Fix patch for this issue (2.67 KB, patch)
2010-04-28 06:52 UTC, lihuiibm
no flags Details | Diff
New patch according to noel's comments (2.85 KB, patch)
2010-04-28 14:55 UTC, lihuiibm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description lihuiibm 2010-04-27 07:50:19 UTC
Selection change event of worksheet does not work well when the prompt a
messagebox in the event, I think because sc fire the selection change event when
mouse click down. I don't have a solution yet. Please try the test sample file.
Comment 1 lihuiibm 2010-04-27 07:54:44 UTC
Created attachment 69137 [details]
Test sample for this issue
Comment 2 noel.power 2010-04-27 09:11:00 UTC
ah this sounds familiar, the problem is the listener fires selection change
events while the button is pressed down. It should be easy enough to fix, you
need to modify the ScTabViewEventListener ( in sc/source/ui/unoobj/viewuno.cxx )
to only fire the selection change event when the mouse button is released. The
listener already gets mouse pressed and release events so it should be easy
enough to detect the start of a selection event ( e.g getting selectionChanged
while the mouse button is down ) and then delay firing of the selection changed
event until the mouse button is released. Can you have a look? 
Comment 3 lihuiibm 2010-04-27 09:15:59 UTC
yes, sure. I'll take a look.
Comment 4 lihuiibm 2010-04-28 06:52:51 UTC
Created attachment 69155 [details]
Fix patch for this issue
Comment 5 noel.power 2010-04-28 09:43:58 UTC
just looking at the patch it seems that you will trigger a selection change
event when releasing the mouse button *always*.
I didn't test this patch but it looks like  ( from the code ) that if there was
a pre-existing selection and you pushed the mouse button you *might* get a
selection change event for for the old selection. Also it looks like if you
push/release the button you will get a selection change event even if no
selection change took place. It seems to me that you need to track whether a
selection change event really occurred ( when releasing the button ) 

e.g have a state mbselectionChangeOccured that you use to decide when to trigger
the change event. I think the logic for forwarding the event should be something
like..

1. when you detect a button press, clear  mbselectionChangeOccured
2. when you get a selection change event from the listener set
mbselectionChangeOccured
3. when you detect a button release if bselectionChangeOccured then forward the
change event to the vba listener

of course beware, all the above is untested and just my impression from looking
at the code ( but I think it it closer to what we need ) what do you think?
Comment 6 lihuiibm 2010-04-28 14:55:24 UTC
Created attachment 69161 [details]
New patch according to noel's comments
Comment 7 noel.power 2010-05-04 15:01:42 UTC
patch looks good, the only question I would have is if flag bDelaySelectionEvent
is really needed? I guess looking at the code its possible to get the selection
changed event *after* the mouse button is released? is that why the extra flag
is there? 
Comment 8 lihuiibm 2010-05-05 02:44:19 UTC
Because selection change event should be triggered until released left button of
mouse, but the event should be triggered once pressed right button of mouse. So
I add the variable bDelaySelectionEvent
Comment 9 noel.power 2010-05-06 09:56:03 UTC
> but the event should be triggered once pressed right button of mouse
oh really? I didn't know that, great work then, patch looks perfect then
Comment 10 Pedro Giffuni 2013-01-23 18:19:09 UTC
Looks like a From Symphony issue?
Comment 11 Marcus 2017-05-20 11:29:46 UTC
Reset assigne to the default "issues@openoffice.apache.org".