Skip to content

Commit

Permalink
added documentation for shared methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Aug 25, 2021
1 parent deedca6 commit 9086c9e
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 26 deletions.
Binary file modified Build/Components/4DPop QuickOpen.4dbase/4DPop QuickOpen.4DZ
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- QUICK_OPEN() -->
## Description
`QUICK_OPEN` display the quick open dialog

## Usage

Call `QUICK_OPEN` from your code. For example, a button.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!-- quickOpenEventHandler() -> $caught : Boolean -->

## Description

`quickOpenEventHandler` first tests the modifier, then the key and finally whether we are in design process. If all tests are satisfied, the quick open dialog is displayed.

## Syntax

`quickOpenEventHandler() ➞ Boolean`

## Usage

See the [complete documentation](https://github.com/vdelachaux/4DPop-QuickOpen/blob/master/README.md)


### A - If you do not use an event-catching method

Create, if any, the database method On startup and enter this code:

```4d
If (Not(Is compiled mode))
ARRAY TEXT($componentsArray; 0)
COMPONENT LIST($componentsArray)
If (Find in array($componentsArray; "4DPop QuickOpen")>0)
// Installing quickOpen
EXECUTE METHOD("quickOpenInit"; *; Formula(MODIFIERS); Formula(KEYCODE))
ON EVENT CALL("quickOpenEventHandler"; "$quickOpenListener")
End if
End if
```


### B - If you already use an event-catching method

1 - Call the init method before installing your event-catching method. Something like:

```4d
ARRAY TEXT($componentsArray; 0)
COMPONENT LIST($componentsArray)
If (Find in array($componentsArray; "4DPop QuickOpen")>0)
// Installing quickOpen
EXECUTE METHOD("quickOpenInit"; *; Formula(MODIFIERS); Formula(KEYCODE))
End if
ON EVENT CALL("MY_METHOD"; "$eventHandler")
```


2 - Modify your event-catching method like this:

```4d
var $quickOpen : Boolean
// Only in development mode
If (Not(Is compiled mode(*)))
// Only if the component is loaded
ARRAY TEXT($components; 0)
COMPONENT LIST($components)
If (Find in array($components; "4DPop QuickOpen")>0)
// Is it a quickOpen call?
EXECUTE METHOD("quickOpenEventHandler"; $quickOpen)
End if
End if
If (Not($quickOpen))
// <THE DATABASE EVENT HANDLER CODE>
End if
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- quickOpenInit(Formula(MODIFIERS); Formula(KEYCODE) {; modifierBit {; keyCode }}) -->
## Description

`quickOpenInit` must be called once, generally in the `On Startup` method to initialize the QuickOpen component and eventually set the main shortcut.

## Syntax

`quickOpenInit()`

## Usage

See the [quickOpenEventHandler method documentation](quickOpenEventHandler.md) or the [complete documentation](https://github.com/vdelachaux/4DPop-QuickOpen/blob/master/README.md)
2 changes: 1 addition & 1 deletion Build/Components/4DPop QuickOpen.4dbase/Info.plist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>NSHumanReadableCopyright</key> <string>©VDL 2021</string> <key>CFBundleVersion</key> <string>11</string> <key>CFBundleDisplayName</key> <string>4DPop QuickOpen</string> <key>CFBundleShortVersionString</key> <string>19</string> <key>CFBundleGetInfoString</key> <string>4DPop QuickOpen</string> <key>CFBundleLongVersionString</key> <string>19</string> <key>CFBundleName</key> <string>4DPop QuickOpen</string> </dict></plist>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>NSHumanReadableCopyright</key> <string>©VDL 2021</string> <key>CFBundleVersion</key> <string>14</string> <key>CFBundleDisplayName</key> <string>4DPop QuickOpen</string> <key>CFBundleShortVersionString</key> <string>19</string> <key>CFBundleGetInfoString</key> <string>4DPop QuickOpen</string> <key>CFBundleLongVersionString</key> <string>19</string> <key>CFBundleName</key> <string>4DPop QuickOpen</string> </dict></plist>
Expand Down
Binary file modified Build/Components/4DPop QuickOpen.4dbase/Libraries/lib4d-arm64.dylib
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions Documentation/Methods/QUICK_OPEN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- QUICK_OPEN() -->
## Description
`QUICK_OPEN` display the quick open dialog

## Usage

Call `QUICK_OPEN` from your code. For example, a button.
82 changes: 82 additions & 0 deletions Documentation/Methods/quickOpenEventHandler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!-- quickOpenEventHandler() -> $caught : Boolean -->

## Description

`quickOpenEventHandler` first tests the modifier, then the key and finally whether we are in design process. If all tests are satisfied, the quick open dialog is displayed.

## Syntax

`quickOpenEventHandler() ➞ Boolean`

## Usage

See the [complete documentation](https://github.com/vdelachaux/4DPop-QuickOpen/blob/master/README.md)


### A - If you do not use an event-catching method

Create, if any, the database method On startup and enter this code:

```4d
If (Not(Is compiled mode))
ARRAY TEXT($componentsArray; 0)
COMPONENT LIST($componentsArray)
If (Find in array($componentsArray; "4DPop QuickOpen")>0)
// Installing quickOpen
EXECUTE METHOD("quickOpenInit"; *; Formula(MODIFIERS); Formula(KEYCODE))
ON EVENT CALL("quickOpenEventHandler"; "$quickOpenListener")
End if
End if
```


### B - If you already use an event-catching method

1 - Call the init method before installing your event-catching method. Something like:

```4d
ARRAY TEXT($componentsArray; 0)
COMPONENT LIST($componentsArray)
If (Find in array($componentsArray; "4DPop QuickOpen")>0)
// Installing quickOpen
EXECUTE METHOD("quickOpenInit"; *; Formula(MODIFIERS); Formula(KEYCODE))
End if
ON EVENT CALL("MY_METHOD"; "$eventHandler")
```


2 - Modify your event-catching method like this:

```4d
var $quickOpen : Boolean
// Only in development mode
If (Not(Is compiled mode(*)))
// Only if the component is loaded
ARRAY TEXT($components; 0)
COMPONENT LIST($components)
If (Find in array($components; "4DPop QuickOpen")>0)
// Is it a quickOpen call?
EXECUTE METHOD("quickOpenEventHandler"; $quickOpen)
End if
End if
If (Not($quickOpen))
// <THE DATABASE EVENT HANDLER CODE>
End if
```

12 changes: 12 additions & 0 deletions Documentation/Methods/quickOpenInit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- quickOpenInit(Formula(MODIFIERS); Formula(KEYCODE) {; modifierBit {; keyCode }}) -->
## Description

`quickOpenInit` must be called once, generally in the `On Startup` method to initialize the QuickOpen component and eventually set the main shortcut.

## Syntax

`quickOpenInit()`

## Usage

See the [quickOpenEventHandler method documentation](quickOpenEventHandler.md) or the [complete documentation](https://github.com/vdelachaux/4DPop-QuickOpen/blob/master/README.md)
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>NSHumanReadableCopyright</key> <string>©VDL 2021</string> <key>CFBundleVersion</key> <string>11</string> <key>CFBundleDisplayName</key> <string>4DPop QuickOpen</string> <key>CFBundleShortVersionString</key> <string>19</string> <key>CFBundleGetInfoString</key> <string>4DPop QuickOpen</string> <key>CFBundleLongVersionString</key> <string>19</string> <key>CFBundleName</key> <string>4DPop QuickOpen</string> </dict></plist>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>NSHumanReadableCopyright</key> <string>©VDL 2021</string> <key>CFBundleVersion</key> <string>14</string> <key>CFBundleDisplayName</key> <string>4DPop QuickOpen</string> <key>CFBundleShortVersionString</key> <string>19</string> <key>CFBundleGetInfoString</key> <string>4DPop QuickOpen</string> <key>CFBundleLongVersionString</key> <string>19</string> <key>CFBundleName</key> <string>4DPop QuickOpen</string> </dict></plist>
Expand Down
30 changes: 16 additions & 14 deletions Project/Sources/DatabaseMethods/onHostDatabaseEvent.4dm
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
#DECLARE($eventCode : Integer)

// ----------------------------------------------------
Case of

//______________________________________________________
: (Is compiled mode:C492(*))

// <NOTHING MORE TO DO>

//______________________________________________________
: (Not:C34(Bool:C1537(Get database parameter:C643(Is host database a project:K37:99))))

// <NOTHING MORE TO DO>

//______________________________________________________
: ($eventCode=On before host database startup:K74:3)

/*
The host database has just been started, its On Startup method has not been called yet
and will not be called until the execution of this method is finished.
So, if the On Startup method does not exist, we can create it.
*/
ARRAY TEXT:C222($arrPaths; 0x0000)
METHOD GET PATHS:C1163(Path database method:K72:2; $arrPaths; *)

If (Bool:C1537(Get database parameter:C643(Is host database a project:K37:99)))
If (Find in array:C230($arrPaths; "[databaseMethod]/onStartup")=-1)

ARRAY TEXT:C222($arrPaths; 0x0000)
METHOD GET PATHS:C1163(Path database method:K72:2; $arrPaths; *)
var $folder : 4D:C1709.Folder
var $file : 4D:C1709.File
$folder:=Folder:C1567(Folder:C1567(fk database folder:K87:14; *).platformPath; fk platform path:K87:2).folder("Project/Sources/DatabaseMethods")
$file:=File:C1566("/RESOURCES/init"+Choose:C955(Command name:C538(1)="Sum"; "US"; "FR")+".4dm").copyTo($folder; "onStartup.4dm")
RELOAD PROJECT:C1739

// So, if the On Startup method does not exist, we can create it.
If (Find in array:C230($arrPaths; "[databaseMethod]/onStartup")=-1)

var $folder : 4D:C1709.Folder
var $file : 4D:C1709.File
$folder:=Folder:C1567(Folder:C1567(fk database folder:K87:14; *).platformPath; fk platform path:K87:2).folder("Project/Sources/DatabaseMethods")
$file:=File:C1566("/RESOURCES/init"+Choose:C955(Command name:C538(1)="Sum"; "US"; "FR")+".4dm").copyTo($folder; "onStartup.4dm")
RELOAD PROJECT:C1739

End if
End if

//______________________________________________________
Expand Down
8 changes: 7 additions & 1 deletion Project/Sources/DatabaseMethods/onStartup.4dm
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
ON_STARTUP
If (Not:C34(Is compiled mode:C492(*)))

// Installing quickOpen
quickOpenInit(Formula:C1597(MODIFIERS); Formula:C1597(KEYCODE))
ON EVENT CALL:C190("quickOpenEventHandler"; "$quickOpenListener")

End if
8 changes: 0 additions & 8 deletions Project/Sources/Methods/ON_STARTUP.4dm

This file was deleted.

1 change: 0 additions & 1 deletion Project/Sources/folders.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"methods": [
"COMPILER_quickOpen",
"noError",
"ON_STARTUP",
"quickOpen_CALLBACK",
"quickOpen_WORKER"
],
Expand Down
Binary file modified Resources/InfoPlist.strings
Binary file not shown.

0 comments on commit 9086c9e

Please sign in to comment.