Skip to content

Commit 4a14c84

Browse files
authored
Setting to disable default user interaction (#350)
* Reintroduce setting to disable default user interaction behavior of alphaTab * Added new events for mouse events on beats * Bump version * Fixed compilation error
1 parent a643d1d commit 4a14c84

14 files changed

Lines changed: 513 additions & 58 deletions

File tree

Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<DebugType>full</DebugType>
44
<DebugSymbols>true</DebugSymbols>
55

6-
<Version>0.9.6</Version>
7-
<AssemblyVersion>0.9.6.0</AssemblyVersion>
8-
<FileVersion>0.9.6.0</FileVersion>
6+
<Version>0.9.7</Version>
7+
<AssemblyVersion>0.9.7.0</AssemblyVersion>
8+
<FileVersion>0.9.7.0</FileVersion>
99
<Authors>Danielku15</Authors>
1010
<Company>CoderLine</Company>
1111
<Product>AlphaTab</Product>
1212
<NeutralLanguage>en</NeutralLanguage>
1313
<Description>alphaTab is a cross platform music notation and guitar tablature rendering library.</Description>
14-
<Copyright>Copyright © 2019, Daniel Kuschny and Contributors</Copyright>
14+
<Copyright>Copyright © 2020, Daniel Kuschny and Contributors</Copyright>
1515
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
1616
<PackageProjectUrl>https://www.alphatab.net</PackageProjectUrl>
1717
<RepositoryUrl>https://github.com/CoderLine/alphaTab</RepositoryUrl>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Title: BeatMouseDown
2+
JsName: addBeatMouseDown();removeBeatMouseDown()
3+
DomName: alphaTab.beatMouseDown
4+
Category: Events - Player
5+
Description: This event is fired whenever a the user presses the mouse button on a beat.
6+
ShowInSideBar: false
7+
Since: 0.9.7
8+
---
9+
10+
<h2>Description</h2>
11+
<p>
12+
@Html.Raw(Model.String(DocsKeys.Description))
13+
</p>
14+
15+
<h2>Types</h2>
16+
17+
<table class="table table-striped table-condensed type-table">
18+
<tbody>
19+
<tr>
20+
<td><code class="code-badge code-badge-net">Action&lt;Beat&gt; <span>.net</span></code></td>
21+
</tr>
22+
<tr>
23+
<td><code class="code-badge code-badge-js">function(e) <span>JavaScript</span></code></td>
24+
</tr>
25+
</tbody>
26+
</table>
27+
28+
<h2>Parameters</h2>
29+
30+
<table class="table table-striped table-condensed type-table">
31+
<thead>
32+
<tr>
33+
<th>Parameters</th>
34+
<th>Type</th>
35+
<th>Summary</th>
36+
</tr>
37+
</thead>
38+
<tbody>
39+
<tr>
40+
<td><code class="code-badge code-badge-all">args <span>all</span></code></td>
41+
<td><code>AlphaTab.Model.Beat</code></td>
42+
<td>
43+
Beat on which the mouse was pressed.
44+
</td>
45+
</tr>
46+
<tr>
47+
<td><code class="code-badge code-badge-jquery">originalEvent <span>jQuery</span></code></td>
48+
<td><code>MouseEvent</code></td>
49+
<td>
50+
The original mouse event that lead to trigger of the beat event. For the DOM event it is stored in the <code>event.originalEvent</code>
51+
</td>
52+
</tr>
53+
</tbody>
54+
</table>
55+
56+
<h2>Example - C#</h2>
57+
58+
<pre>
59+
<code class="language-csharp line-numbers">
60+
var api = new AlphaTabApi<MyControl>(...);
61+
api.BeatMouseDown += beat =>
62+
{
63+
StartSelectionOnBeat(args);
64+
};
65+
</code>
66+
</pre>
67+
68+
69+
<h2>Example - JavaScript</h2>
70+
71+
<pre>
72+
<code class="language-javascript line-numbers">
73+
var api = new alphaTab.platform.javaScript.AlphaTabApi(document.querySelector('#alphaTab'));
74+
api.addBeatMouseDown(function(beat) {
75+
startSelectionOnBeat(beat);
76+
});
77+
78+
</code>
79+
</pre>
80+
81+
<h2>Example - jQuery</h2>
82+
83+
<pre>
84+
<code class="language-javascript line-numbers">
85+
$('#alphaTab').on('alphaTab.beatMouseDown', function(e, beat) {
86+
originalEvent.preventDefault();
87+
startSelectionOnBeat(beat);
88+
});
89+
</code>
90+
</pre>
91+
92+
<h2>Example - HTML</h2>
93+
94+
<pre>
95+
<code class="language-javaScript line-numbers">
96+
document.querySelector('#alphaTab').addEventListener('alphaTab.beatMouseDown', function(e) {
97+
var beat = e.detail;
98+
e.originalEvent.preventDefault();
99+
startSelectionOnBeat(beat);
100+
}, false);
101+
</code>
102+
</pre>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Title: BeatMouseMove
2+
JsName: addBeatMouseMove();removeBeatMouseMove()
3+
DomName: alphaTab.beatMouseMove
4+
Category: Events - Player
5+
Description: This event is fired whenever the user moves the mouse over a beat after the user already pressed the button on a beat.
6+
ShowInSideBar: false
7+
Since: 0.9.7
8+
---
9+
10+
<h2>Description</h2>
11+
<p>
12+
@Html.Raw(Model.String(DocsKeys.Description))
13+
</p>
14+
15+
<h2>Types</h2>
16+
17+
<table class="table table-striped table-condensed type-table">
18+
<tbody>
19+
<tr>
20+
<td><code class="code-badge code-badge-net">Action&lt;Beat&gt; <span>.net</span></code></td>
21+
</tr>
22+
<tr>
23+
<td><code class="code-badge code-badge-js">function(e) <span>JavaScript</span></code></td>
24+
</tr>
25+
</tbody>
26+
</table>
27+
28+
<h2>Parameters</h2>
29+
30+
<table class="table table-striped table-condensed type-table">
31+
<thead>
32+
<tr>
33+
<th>Parameters</th>
34+
<th>Type</th>
35+
<th>Summary</th>
36+
</tr>
37+
</thead>
38+
<tbody>
39+
<tr>
40+
<td><code class="code-badge code-badge-all">args <span>all</span></code></td>
41+
<td><code>AlphaTab.Model.Beat</code></td>
42+
<td>
43+
Beat on which the mouse was hovered over during mouse down.
44+
</td>
45+
</tr>
46+
<tr>
47+
<td><code class="code-badge code-badge-jquery">originalEvent <span>jQuery</span></code></td>
48+
<td><code>MouseEvent</code></td>
49+
<td>
50+
The original mouse event that lead to trigger of the beat event. For the DOM event it is stored in the <code>event.originalEvent</code>
51+
</td>
52+
</tr>
53+
</tbody>
54+
</table>
55+
56+
<h2>Example - C#</h2>
57+
58+
<pre>
59+
<code class="language-csharp line-numbers">
60+
var api = new AlphaTabApi<MyControl>(...);
61+
api.BeatMouseMove += beat =>
62+
{
63+
ExpandSelectionToBeat(beat);
64+
};
65+
</code>
66+
</pre>
67+
68+
69+
<h2>Example - JavaScript</h2>
70+
71+
<pre>
72+
<code class="language-javascript line-numbers">
73+
var api = new alphaTab.platform.javaScript.AlphaTabApi(document.querySelector('#alphaTab'));
74+
api.addBeatMouseMove(function(beat) {
75+
expandSelectionToBeat(beat);
76+
});
77+
78+
</code>
79+
</pre>
80+
81+
<h2>Example - jQuery</h2>
82+
83+
<pre>
84+
<code class="language-javascript line-numbers">
85+
$('#alphaTab').on('alphaTab.beatMouseMove', function(e, beat) {
86+
originalEvent.preventDefault();
87+
expandSelectionToBeat(beat);
88+
});
89+
</code>
90+
</pre>
91+
92+
<h2>Example - HTML</h2>
93+
94+
<pre>
95+
<code class="language-javaScript line-numbers">
96+
document.querySelector('#alphaTab').addEventListener('alphaTab.beatMouseMove', function(e) {
97+
var beat = e.detail;
98+
e.originalEvent.preventDefault();
99+
expandSelectionToBeat(beat);
100+
}, false);
101+
</code>
102+
</pre>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Title: BeatMouseUp
2+
JsName: addBeatMouseUp();removeBeatMouseUp()
3+
DomName: alphaTab.beatMouseUp
4+
Category: Events - Player
5+
Description: This event is fired whenever the user releases the mouse after a mouse press on a beat.
6+
7+
ShowInSideBar: false
8+
Since: 0.9.7
9+
---
10+
11+
<h2>Description</h2>
12+
<p>
13+
@Html.Raw(Model.String(DocsKeys.Description))
14+
This event is fired regardless of whether the mouse was released on a beat.
15+
The parameter is null if the mouse was released somewhere beside the beat.
16+
</p>
17+
18+
<h2>Types</h2>
19+
20+
<table class="table table-striped table-condensed type-table">
21+
<tbody>
22+
<tr>
23+
<td><code class="code-badge code-badge-net">Action&lt;Beat&gt; <span>.net</span></code></td>
24+
</tr>
25+
<tr>
26+
<td><code class="code-badge code-badge-js">function(e) <span>JavaScript</span></code></td>
27+
</tr>
28+
</tbody>
29+
</table>
30+
31+
<h2>Parameters</h2>
32+
33+
<table class="table table-striped table-condensed type-table">
34+
<thead>
35+
<tr>
36+
<th>Parameters</th>
37+
<th>Type</th>
38+
<th>Summary</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
<tr>
43+
<td><code class="code-badge code-badge-all">args <span>all</span></code></td>
44+
<td><code>AlphaTab.Model.Beat</code></td>
45+
<td>
46+
Beat on which the mouse was released over after mouse down.
47+
Might be null if no beat could be found in near location.
48+
</td>
49+
</tr>
50+
<tr>
51+
<td><code class="code-badge code-badge-jquery">originalEvent <span>jQuery</span></code></td>
52+
<td><code>MouseEvent</code></td>
53+
<td>
54+
The original mouse event that lead to trigger of the beat event. For the DOM event it is stored in the <code>event.originalEvent</code>
55+
</td>
56+
</tr>
57+
</tbody>
58+
</table>
59+
60+
<h2>Example - C#</h2>
61+
62+
<pre>
63+
<code class="language-csharp line-numbers">
64+
var api = new AlphaTabApi<MyControl>(...);
65+
api.BeatMouseUp += beat =>
66+
{
67+
HideSelection(beat);
68+
};
69+
</code>
70+
</pre>
71+
72+
73+
<h2>Example - JavaScript</h2>
74+
75+
<pre>
76+
<code class="language-javascript line-numbers">
77+
var api = new alphaTab.platform.javaScript.AlphaTabApi(document.querySelector('#alphaTab'));
78+
api.addBeatMouseUp(function(beat) {
79+
hideSelection(beat);
80+
});
81+
82+
</code>
83+
</pre>
84+
85+
<h2>Example - jQuery</h2>
86+
87+
<pre>
88+
<code class="language-javascript line-numbers">
89+
$('#alphaTab').on('alphaTab.beatMouseUp', function(e, beat) {
90+
originalEvent.preventDefault();
91+
hideSelection(beat);
92+
});
93+
</code>
94+
</pre>
95+
96+
<h2>Example - HTML</h2>
97+
98+
<pre>
99+
<code class="language-javaScript line-numbers">
100+
document.querySelector('#alphaTab').addEventListener('alphaTab.beatMouseUp', function(e) {
101+
var beat = e.detail;
102+
e.originalEvent.preventDefault();
103+
hideSelection(beat);
104+
}, false);
105+
</code>
106+
</pre>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Title: Player.EnableUserInteraction
2+
JsName: player.enableUserInteraction
3+
JsonName: player.enableUserInteraction
4+
DataAttribute: data-player-enableuserinteraction
5+
Category: Player
6+
Description: Gets or sets whether the player should be enabled.
7+
ShowInSideBar: false
8+
Since: 0.9.6
9+
---
10+
11+
<h2>Description</h2>
12+
<p>
13+
This setting configures whether alphaTab provides the default user interaction features like selection of the playback range and "seek on click".
14+
By default users can select the desired playback range with the mouse and also jump to individual beats by click. This behavior can be contolled w1ith this setting.
15+
</p>
16+
17+
@Html.Partial("_PropertyDescription", Model)
18+
19+
<h2>Types</h2>
20+
21+
<table class="table table-striped table-condensed type-table">
22+
<tbody>
23+
<tr>
24+
<td><code>bool</code></td>
25+
</tr>
26+
</tbody>
27+
</table>
28+
29+
<h2>Default Value</h2>
30+
31+
<code>true</code>

Source/AlphaTab.CSharp/Platform/CSharp/ManagedUiFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public IAlphaSynth CreateWorkerPlayer()
6161
public abstract event Action RootContainerBecameVisible;
6262
public abstract void Destroy();
6363
public abstract IContainer CreateCanvasElement();
64-
public abstract void TriggerEvent(IContainer container, string eventName, object details = null);
64+
public abstract void TriggerEvent(IContainer container, string eventName, object details = null, IMouseEventArgs originalEvent = null);
6565

6666
public virtual void InitialRender()
6767
{

Source/AlphaTab.CSharp/Platform/CSharp/WinForms/WinFormsUiFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public override IContainer CreateCanvasElement()
112112
return new ControlContainer(_layoutPanel);
113113
}
114114

115-
public override void TriggerEvent(IContainer container, string eventName, object details = null)
115+
public override void TriggerEvent(IContainer container, string eventName, object details = null, IMouseEventArgs originalEvent = null)
116116
{
117117
}
118118

Source/AlphaTab.CSharp/Platform/CSharp/Wpf/WpfUiFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public override IContainer CreateCanvasElement()
118118
return new FrameworkElementContainer(canvas);
119119
}
120120

121-
public override void TriggerEvent(IContainer container, string eventName, object details = null)
121+
public override void TriggerEvent(IContainer container, string eventName, object details = null, IMouseEventArgs originalEvent = null)
122122
{
123123
}
124124

0 commit comments

Comments
 (0)