Page 1 of 1

Framework is difficult

Posted: Sat Jan 28, 2017 8:50 am
by DGDanforth
I would like to clean up a large portion of the documentation for BB.
I think that will take all of us working together.
In general I find it difficult to use and understand.
Some parts are much better than others.

Right now I am struggling to understand why the focus frame does not have a rider.

Code: Select all

focusFrame := Controllers.FocusFrame();
focusFrame.SetCursor(Ports.refCursor);
crashes because the rider is NIL. Why?
The documentation on this point is opaque.

Comments?
-Doug

Re: Framework is difficult

Posted: Sat Jan 28, 2017 4:56 pm
by Ivan Denisov
Because there can be situation without focus frame?

Code: Select all

    focusFrame := Controllers.FocusFrame();
    IF focusFrame # NIL THEN
        focusFrame.SetCursor(Ports.refCursor);
    END;

Re: Framework is difficult

Posted: Sun Jan 29, 2017 1:43 am
by DGDanforth
Ivan Denisov wrote:Because there can be situation without focus frame?

Code: Select all

    focusFrame := Controllers.FocusFrame();
    IF focusFrame # NIL THEN
        focusFrame.SetCursor(Ports.refCursor);
    END;
Ivan,
The focusFrame is not NIL and yet it does not have a rider.
I am hypothesizing that the call to the function, say, GetFrame
is done by a Commander and that the focus is actually the
commander and not the document in which the commander
is embedded. If true then that means the getting of the focus
must be activated either by a menu or by, say, a tools dialog.

Again, the complexity of this not trivial.
-Doug

Re: Framework is difficult

Posted: Mon Jan 30, 2017 5:54 am
by DGDanforth
When does a frame have a rider?

Re: Framework is difficult

Posted: Mon Jan 30, 2017 7:43 am
by Ivan Denisov
DGDanforth wrote:When does a frame have a rider?
The more interesting question, when does a frame have no rider? Doug, can you please describe your case with some more details. There is clear stated in documentation, that usually developer should not care about this riders. That is an element of internal realization of the framework. So how did you catch this bug?

Re: Framework is difficult

Posted: Mon Jan 30, 2017 8:57 am
by Josef Templ
The only place where the rider of a Ports.Frame is set is Ports.Frame.ConnectTo.
This is called directly at the following places:

Views.InstallFrame
Views.Close
Documents.Print
Windows.Open
OLEData.Paint
HostBitmaps.Paint

If a rider is not set, the frame is unconnected., i.e. not connected to
a graphics device (display or printer) that defines the pixel size.
The focus frame as returned by Controllers.FocusFrame seems to be
unconnected when called from an ordinary command.
It may be different when called from within a view's message handler.

The docu of SetFocus() says "SetCursor is used in polling loops during mouse tracking."
and at that point it seems that the frame is connected.
Other usages are probably not intended but this is not stated explicitly
(or maybe it is but somewhere else).

- Josef

Re: Framework is difficult

Posted: Mon Jan 30, 2017 9:21 am
by DGDanforth
A trap is called when the following is executed

Code: Select all

focusFrame.SetCursor(Ports.refCursor);
but only in a specific case that I have not yet been able to isolate.

When I wrap a view I get a focusFrame whose rider is not NIL (good)
but some where else when I then do a SetCursor with
the same focusFrame the rider is now NIL (bad).

I don't see how the focusFrame is modified.

Re: Framework is difficult

Posted: Mon Jan 30, 2017 9:38 am
by DGDanforth
I just did a test using SYSTEM.ADR.
The pointer focusFrame is not changed between where it was created
and where SetCursor is called. So something has modified the focusFrame internals.
-Doug

Re: Framework is difficult

Posted: Mon Jan 30, 2017 1:14 pm
by Ivan Denisov
I agree with Doug, that there is lack of developers documentation about framework. When you work with wrapping there are some requirements.

Are you doing you wrapping like it is done in ObxWrappers ?