Potential bug when using zoom-buttons within the preview?
Hi,
based on these two examples from the rb-Wiki
1)
http://www.digital-metaphors.com/rbWiki/Output/Preview/How_To...Preview_in_a_Panel
2)
http://www.digital-metaphors.com:8080/Output/Preview/How_To...Add_a_Button_to_the_Preview
I'm creating and using my own preview in a panel with two additional buttons
to zoom the viewer in and out.
The buttons have this in their OnClick event:
ZoomToPercentage(Viewer.ZoomPercentage + 10);
or
ZoomToPercentage(Viewer.ZoomPercentage - 10);
respectively.
While implementing this I eventually discovered a bug:
- when the preview is showed first time
- when I click on one of the buttons: PageWidthButton, WholePageButton,
Percent100Button
- when resizing my window with the parent of the viewer on it
the value of Viewer.ZoomPercentage is not the same as it is in
ZoomPercentageEdit.Text (which is being changed after all of those 3 actions
mentioned above).
Once I click on one of my own buttons, the viewer is jumping to the value of
Viewer.ZoomPercentage first and only after that I can zoom in or out with my
buttons properly.
Shouldn't the value of Viewer.ZoomPercentage be always the same as the value
of ZoomPercentageEdit.Text?
I thought it should, so I did override the OnClick event of the buttons
PageWidthButton, WholePageButton, Percent100Button:
inherited;
Viewer.ZoomPercentage := StrToInt(StringReplace(ZoomPercentageEdit.Text,
'%', '', []));
For these 3 buttons it works then, though once I click at one of them, the
ZoomPercentageEdit.Text isn't being updated on resize anymore.
So at least to me it looks as if there are some issues with the zoom
functionality or am I wrong?
Regards,
Mark
based on these two examples from the rb-Wiki
1)
http://www.digital-metaphors.com/rbWiki/Output/Preview/How_To...Preview_in_a_Panel
2)
http://www.digital-metaphors.com:8080/Output/Preview/How_To...Add_a_Button_to_the_Preview
I'm creating and using my own preview in a panel with two additional buttons
to zoom the viewer in and out.
The buttons have this in their OnClick event:
ZoomToPercentage(Viewer.ZoomPercentage + 10);
or
ZoomToPercentage(Viewer.ZoomPercentage - 10);
respectively.
While implementing this I eventually discovered a bug:
- when the preview is showed first time
- when I click on one of the buttons: PageWidthButton, WholePageButton,
Percent100Button
- when resizing my window with the parent of the viewer on it
the value of Viewer.ZoomPercentage is not the same as it is in
ZoomPercentageEdit.Text (which is being changed after all of those 3 actions
mentioned above).
Once I click on one of my own buttons, the viewer is jumping to the value of
Viewer.ZoomPercentage first and only after that I can zoom in or out with my
buttons properly.
Shouldn't the value of Viewer.ZoomPercentage be always the same as the value
of ZoomPercentageEdit.Text?
I thought it should, so I did override the OnClick event of the buttons
PageWidthButton, WholePageButton, Percent100Button:
inherited;
Viewer.ZoomPercentage := StrToInt(StringReplace(ZoomPercentageEdit.Text,
'%', '', []));
For these 3 buttons it works then, though once I click at one of them, the
ZoomPercentageEdit.Text isn't being updated on resize anymore.
So at least to me it looks as if there are some issues with the zoom
functionality or am I wrong?
Regards,
Mark
This discussion has been closed.
Comments
If possible, please send the example with the changes you've made
demonstrating this behavior to support@digital-metaphors.com in .zip format
and I'll take a look at it for you.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
sample project sent via e-mail.
Mark
Thanks for the example.
The Viewer.ZoomPercentage is not meant to be updated when the
PreviewFormSettings.ZoomSetting is anything other than zsPercentage. This
is why on an initial load, the ZoomPercentage remains as the default value
of 100 rather than the calculated percentage of 56. To easily correct the
issue you are seeing, try using the Viewer.CalculatedZoom property rather
than ZoomPercentage.
procedure TCustomPreviewPlugin.ZoomPlusButtonKlick;
begin
ZoomToPercentage(Viewer.CalculatedZoom + 10);
end;
procedure TCustomPreviewPlugin.ZoomMinusButtonKlick;
begin
ZoomToPercentage(Viewer.CalculatedZoom - 10);
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
yes, the CalculatedZoom-property works much better and no manual changes are
needed.
Thank you for your help!
Mark