Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Ensure "ideNewControl" msg is sent when importing an image from the IDE #2017

Open
wants to merge 2 commits into
base: develop-9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Toolset/libraries/revidelibrary.8.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -7221,6 +7221,9 @@ on revIDEImportControl pType, pFileName, pReferenced
set the name of tCreatedControlID to the last item of pFileName
unlock messages
unlock screen
if not (pReferenced is true) then
ideMessageSend "ideNewControl", tCreatedControlID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@livecodepanos There's a few things I'm noticing here:

  1. I'm not sure why with the image creation we are doing:
put the long id of the last control into tCreatedControlID

after revIDECreateObject Instead of:

put the result into tCreatedControlID
  1. There are cases where pReferenced is true and ideNewControl will be sent by revIDECreateObject (referenced video) and cases where pReferenced is not true and ideNewControl will not be sent (audio).

  2. revIDECreateObject does this so we probably need to do that in cases where it is sent here:

   ## Prevent passing of ideNewControl message for objects created on IDE stacks
   if revIDEObjectIsOnIDEStack(tCreatedControlID) is false then
      // AL-2015-04-08: [[ Bug 14822 ]] Ensure 'edited' status of stack is set
      revIDESetEdited the short name of this stack
      ideMessageSend "ideNewControl", tCreatedControlID
   end if

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... one other thing... in the case of imported images I think we could use revIDECreateObject then:

set the text of tCreatedControlID to url ("binfile:" & pFilename)

But if we need to send the message for other imported things here then maybe no need to change that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@livecodepanos thinking about this a little bit more I can't help wondering if we should move the import cases into revIDECreateObject... say by adding an optional pFilename parameter. I think that might simplify maintenance as all object creation is done in one handler and only setting of extra properties due to it being an import operation happens here. Then the image case for example just becomes:

          if pReferenced is true then
              revIDECreateObject "com.livecode.interface.classic.image", tTargetStack, tCreatedControlLocation
          else
              revIDECreateObject "com.livecode.interface.classic.image", tTargetStack, tCreatedControlLocation, pFilename
          end if
          put the result into tCreatedControlID
         if pFileName ends with ".svg" then
             -- SVG files can't be referenced
             set the text of tCreatedControlID to drawingSvgCompileFile(pFileName)
          else if pReferenced is true then
              set the filename of tCreatedControlID to pFileName
          end if
          set the borderWidth of tCreatedControlID to 0
          select tCreatedControlID

end if
return tCreatedControlID
end revIDEImportControl

Expand Down
1 change: 1 addition & 0 deletions notes/bugfix-19156.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Ensure "ideNewControl" message is sent when adding an imported image from the IDE