You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mouse events come not only from "mouse manipulators", but are also emulated on touch devices, to make them compatible.
3
+
Fare olayları yalnızca "fare olayi ya da manipülasyonu" ile gerçekleşmez, aynı zamanda dokunmatik cihazlara da uyumlu hale getirmek için bu cihazlarda taklit edilir.
4
4
5
-
In this chapter we'll get into more details about mouse events and their properties.
5
+
Bu bölümde fare olayları ve özellikleri hakkında daha fazla ayrıntıya gireceğiz.
6
6
7
-
## Mouse event types
7
+
## Fare olay türleri
8
8
9
-
We can split mouse events into two categories: "simple" and "complex"
9
+
Fare olaylarını "basit" ve "karmaşık" olarak iki kategoriye ayırabiliriz.
10
10
11
-
### Simple events
11
+
### Basit fare olayları
12
12
13
-
The most used simple events are:
13
+
En çok kullanılan basit olaylar şunlardır:
14
14
15
-
`mousedown/mouseup`
16
-
: Mouse button is clicked/released over an element.
15
+
`mousedown/mouseup`
16
+
: Fare ile bir öğenin üzerine tıklanır / bırakılır.
17
17
18
18
`mouseover/mouseout`
19
-
: Mouse pointer comes over/out from an element.
19
+
: Fare ile bir öğenin üzerine gelinir / uzaklaşılır.
20
20
21
21
`mousemove`
22
-
: Every mouse move over an element triggers that event.
22
+
: Bir öğenin üzerine yapılan her fare bu olayı tetikler.
23
23
24
-
...There are several other event types too, we'll cover them later.
24
+
...Başka olay türleri de var, bunları daha sonra ele alacağız.
25
25
26
-
### Complex events
26
+
### Karmaşık fare olayları
27
27
28
28
`click`
29
-
: Triggers after `mousedown`and then`mouseup`over the same element if the left mouse button was used.
29
+
: Farenin sol tuşuna basıldığında, aynı öğe üzerinde `mousedown`ve ardından`mouseup`olayının gerçekleşmesi ile tetiklenir.
30
30
31
31
`contextmenu`
32
-
: Triggers after `mousedown`if the right mouse button was used.
32
+
: Farenin sağ tuşuna basıldığında, `mousedown`olayı gerçekleşirse tetiklenir.
33
33
34
34
`dblclick`
35
-
: Triggers after a double click over an element.
35
+
: Bir ögenin üzerine çift tıklandıktan sonra tetiklenir.
36
36
37
-
Complex events are made of simple ones, so in theory we could live without them. But they exist, and that's good, because they are convenient.
37
+
Karmaşık olaylar basit olayların birleşimi, bu yüzden teoride onlarsız da işlerimizi görebiliriz. Ama karmaşık olayların var olmaları iyi çünkü kullanışlılar.
38
38
39
-
### Events order
39
+
### Olay sırası
40
40
41
-
An action may trigger multiple events.
41
+
Bir eylem birden fazla fare olayı tetikleyebilir.
42
42
43
-
For instance, a click first triggers `mousedown`, when the button is pressed, then`mouseup`and `click`when it's released.
43
+
Örneğin, bir tıklama, düğmeye basıldığında önce `mousedown` olayını, ardından`mouseup`olayını ve fare butonu bırakıldığında `click`olayını tetikler.
44
44
45
-
In cases when a single action initiates multiple events, their order is fixed. That is, the handlers are called in the order `mousedown` -> `mouseup` -> `click`. Events are handled in the same sequence: `onmouseup` finishes before `onclick` runs.
45
+
Tek bir eylemin birden çok fare olayı başlattığı durumlarda, bunların sırası sabittir. İşleyiciler her zaman şu sıraya göre çağırılır: `mousedown` -> `mouseup` -> `click`. Olaylar aynı sırayla işlenir: önce `onclick` çalışır sonra `onmouseup`.
46
46
47
-
```online
48
-
Click the button below and you'll see the events. Try double-click too.
47
+
````online
48
+
Gerçekleşen eylemleri görmek için aşağıdaki butonu tıkla. Çift tıklamayı da dene.
49
49
50
-
On the teststand below all mouse events are logged, and if there are more than 1 second delay between them, then they are separated by a horizontal ruler.
50
+
Aşağıdaki test standında, tüm fare olayları kaydedilir ve aralarında 1 saniyeden fazla gecikme varsa, yatay bir cetvel ile ayrılırlar.
51
51
52
-
Also we can see the `which` property that allows to detect the mouse button.
52
+
Ayrıca, fare butonuna tıklandıgında algılanmasını sağlayan "which" özelliğini görebilirsiniz.
53
53
54
54
<input onmousedown="return logMouse(event)" onmouseup="return logMouse(event)" onclick="return logMouse(event)" oncontextmenu="return logMouse(event)" ondblclick="return logMouse(event)" value="Click me with the right or the left mouse button" type="button"> <input onclick="logClear('test')" value="Clear" type="button"> <form id="testform" name="testform"> <textarea style="font-size:12px;height:150px;width:360px;"></textarea></form>
55
55
```
56
56
57
-
## Getting the button: which
57
+
Tıklamayla ilgili bütün olaylar `button` özelliğine sahiptir ve bu da olayın tam olarak hangi fare butonu ile çalıştığını bulmamızı sağlar.
58
+
59
+
`click` ve `contextmenu` olayları için kullanılamaz çünkü `click` sadece sol tıklamada, `contextmenu` sadece sağ tıklamada gerçekleşir.
60
+
61
+
Ancak `mousedown` ve `mouseup` olaylarını takip etmek istersek, o zaman `button` özelliğine ihtiyacımız olur, çünkü bu olaylar herhangi bir fare butonu ile gerçekleşebilir, bu yüzden `button` "right-mousedown" (sağ- tıklama) ile "left-mousedown" (sol-tıklama) olayını ayırt etmemizi sağlar.
62
+
63
+
Üç olası değer vardır:
58
64
59
-
Click-related events always have the `which` property, which allows to get the exact mouse button.
65
+
| Button State | event.button |
66
+
| Sol tuşa tıklama | 0 |
67
+
| Orta tuşa tıklama | 1 |
68
+
| Sağ tuşa tıklama | 2 |
69
+
| X1 tuşa tıklama (geri tuşu) | 3 |
70
+
| X2 tuşa tıklama (ileri tuşu) | 4 |
60
71
61
-
It is not used for `click` and `contextmenu` events, because the former happens only on left-click, and the latter -- only on right-click.
72
+
Çoğu fare aygıtında yalnızca sol ve sağ düğmeler bulunur, bu nedenle olası değerler 0 veya 2'dir. Dokunmatik aygıtlar da üzerlerine bir kez dokunduğunda benzer olaylar oluşturur.
62
73
63
-
But if we track `mousedown` and `mouseup`, then we need it, because these events trigger on any button, so `which` allows to distinguish between "right-mousedown" and "left-mousedown".
74
+
Ayrıca, o anda basılan tüm düğmelere düğme başına bir bit olmak üzere tamsayı olarak sahip olan `event.buttons` özelliği vardır. Uygulamada bu özellik çok nadiren kullanılır, ihtiyacınız olursa [MDN](https://developer.mozilla.org/en-US/docs/Web/api/MouseEvent/buttons)'de ayrıntıları bulabilirsiniz.
64
75
65
-
There are the three possible values:
76
+
## Zamanı geçmiş which butonu
66
77
67
-
-`event.which == 1` -- the left button
68
-
-`event.which == 2` - the middle button
69
-
-`event.which == 3` - the right button
78
+
Eski kodlar, olası değerlerle buton elde etmenin eski bir yolu olan event.which özelliğini kullanabilir:
70
79
71
-
The middle button is somewhat exotic right now and is very rarely used.
80
+
- `event.which == 1` -- sol tuşa tıklama
81
+
- `event.which == 2` - orta tuşa tıklama
82
+
- `event.which == 3` - sağ tuşa tıklama
72
83
73
-
## Modifiers: shift, alt, ctrl and meta
84
+
**Şu an itibariyle artık kullanımdan kaldırılan event.which olayını artık kullanmamalıyız.**
74
85
75
-
All mouse events include the information about pressed modifier keys.
86
+
## Değiştiriciler: shift, alt, ctrl and meta
76
87
77
-
The properties are:
88
+
Tüm fare olayları, basılan değiştirici tuşlarla ilgili bilgileri içerir.
89
+
90
+
Özellikler (properties):
78
91
79
92
- `shiftKey`
80
93
- `altKey`
81
94
- `ctrlKey`
82
-
-`metaKey` (`key:Cmd`for Mac)
95
+
- `metaKey` (`key:Cmd` Mac için)
83
96
84
-
For instance, the button below only works on `key:Alt+Shift`+click:
97
+
Örneğin, aşağıdaki düğme yalnızca `Alt+Shift`+fare tıklaması ile beraber çalışır:
85
98
86
99
```html autorun height=60
87
-
<buttonid="button">Alt+Shift+Click on me!</button>
@@ -97,62 +110,64 @@ For instance, the button below only works on `key:Alt+Shift`+click:
97
110
</script>
98
111
```
99
112
100
-
```warn header="Attention: on Mac it's usually `Cmd` instead of `Ctrl`"
101
-
On Windows and Linux there are modifier keys `key:Alt`, `key:Shift` and `key:Ctrl`. On Mac there's one more: `key:Cmd`, it corresponds to the property `metaKey`.
113
+
```warn header="Dikkat: Mac için genellikle `Ctrl` yerine `Cmd` kullanılır."
114
+
Windows ve Linux işletim sistemlerinde `key:Alt`, `key:Shift` and `key:Ctrl` değiştiricileri bulunur. Mac için bir değiştirici daha var: `key:Cmd`, bu `metaKey` özelliğine karşılık gelir.
102
115
103
-
In most cases when Windows/Linux uses `key:Ctrl`, on Mac people use `key:Cmd`. So where a Windows user presses `key:Ctrl+Enter`or `key:Ctrl+A`, a Mac user would press `key:Cmd+Enter`or `key:Cmd+A`, and so on, most apps use `key:Cmd` instead of `key:Ctrl`.
116
+
Çoğu zaman Windows/Linux üzerinde bir durum için `key:Ctrl` kullanılırken, Mac üzerinde `key:Cmd` kullanılır. Bu yüzden Windows kullanıcısı `key:Ctrl+Enter` ya da `key:Ctrl+A` kullandığı zaman, Mac kullanıcısı `key:Cmd+Enter` ya da `key:Cmd+A` kullanır. Bir çok uygulama da `key:Ctrl` yerine `key:Cmd` kullanır.
104
117
105
-
So if we want to support combinations like `key:Ctrl`+click, then for Mac it makes sense to use `key:Cmd`+click. That's more comfortable for Mac users.
118
+
Dolayısıyla, Ctrl + tıklama gibi kombinasyonları kullanacagımız zaman, Mac için Cmd + tıklamayı kullanmak mantıklıdır. Bu, Mac kullanıcıları için fiziksel açıdan da daha rahat bir çözümdür.
106
119
107
-
Even if we'd like to force Mac users to `key:Ctrl`+click -- that's kind of difficult. The problem is: a left-click with `key:Ctrl`is interpreted as a *right-click* on Mac, and it generates the `contextmenu` event, not `click` like Windows/Linux.
120
+
Mac kullanıcılarını `key:Ctrl` + tıklama yapmaya zorlasak bile sorun şudur: `key:Ctrl` ile sol tıklama, Mac'te *sağ tıklama* olarak yorumlanır ve Windows / Linux gibi `click` değil, `contextmenu` olayını oluşturur.
108
121
109
-
So if we want users of all operational systems to feel comfortable, then together with `ctrlKey`we should use `metaKey`.
122
+
Dolayısıyla, tüm işletim sistemlerinin kullanıcılarının kendilerini rahat hissetmelerini istiyorsak, o zaman `ctrlKey` ile birlikte `metaKey` kullanmalıyız.
110
123
111
-
For JS-code it means that we should check `if (event.ctrlKey || event.metaKey)`.
124
+
JS kodu için bu, `if (event.ctrlKey || event.metaKey) şeklinde tuşları kontrol etmemiz gerektiği anlamına gelir.
112
125
```
113
126
114
-
```warn header="There are also mobile devices"
115
-
Keyboard combinations are good as an addition to the workflow. So that if the visitor has a
116
-
keyboard -- it works. And if your device doesn't have it -- then there's another way to do the same.
127
+
```warn header="Hesaba katmamız gereken bir başka durum da mobil cihazlar"
128
+
Klavye kombinasyonları ziyaretçinin klavyesi varsa çalışır.
129
+
Ancak eğer kullanıcı klavyesiz kullanıyorsa -- o zaman aynısını yapmanın başka bir yolu var.
117
130
```
118
131
119
-
## Coordinates: clientX/Y, pageX/Y
132
+
## Koordinatlar: clientX/Y, pageX/Y
133
+
134
+
Tüm fare olaylarının iki farklı türde koordinatları vardır:
120
135
121
-
All mouse events have coordinates in two flavours:
136
+
1. Pencereye bağlı koordinatlar (Window-relative): `clientX` ve `clientY`.
137
+
2. Belgeye bağlı koordınatlar (Document-relative): `pageX` ve `pageY`.
122
138
123
-
1. Window-relative: `clientX` and `clientY`.
124
-
2. Document-relative: `pageX` and `pageY`.
139
+
Kısaca, belgeye bağlı koordinatlar pageX / Y, belgenin en sol üst köşesinden sayılır ve sayfa kaydırıldığında da değişmez, clientX / Y ise geçerli pencerenin (wındow) sol üst köşesinden sayılır. Sayfa kaydırıldığında değişirler.
125
140
126
-
For instance, if we have a window of the size 500x500, and the mouse is in the left-upper corner, then `clientX`and`clientY`are `0`. And if the mouse is in the center, then`clientX`and`clientY`are `250`, no matter what place in the document it is. They are similar to `position:fixed`.
141
+
Örneğin, 500x500 boyutunda bir penceremiz varsa ve fare en sol üst köşedeyse, o zaman `clientX` ve `clientY` `0` olur. Fare tam ortadaysa, o zaman belgenin neresinde olursa olsun `clientX` ve `clientY` `250` olur. `position:fixed` ile benzer şekilde çalışır.
127
142
128
143
````online
129
-
Move the mouse over the input field to see `clientX/clientY` (it's in the `iframe`, so coordinates are relative to that `iframe`):
144
+
`clientX/clientY` değerlerini görmek için fare ile üzerinden geç. ("iframe" içinde yapıldı, bu nedenle koordinatlar bu "iframe" e göredir):
130
145
131
146
```html autorun height=50
132
147
<input onmousemove="this.value=event.clientX+':'+event.clientY" value="Mouse over me">
133
148
```
134
149
````
135
150
136
-
Document-relative coordinates are counted from the left-upper corner of the document, not the window.
137
-
Coordinates `pageX`, `pageY` are similar to `position:absolute` on the document level.
151
+
Belgeye bağlı koordinatlar, pencereden değil, belgenin sol üst köşesinden sayılır.
152
+
"PageX", "pageY" koordinatları, belge düzeyinde "position:absolute" ile benzerdir.
138
153
139
-
You can read more about coordinates in the chapter<info:coordinates>.
154
+
Bunlar arasındaki farkı burada daha detaylı olarak işledik<info:coordinates>.
140
155
141
-
## No selection on mousedown
156
+
## mousedown olayında metin seçimini önleme
142
157
143
-
Mouse clicks have a side-effect that may be disturbing. A double click selects the text.
158
+
Fare tıklamalarının rahatsız edici olabilecek bir yan etkisi vardır. Çift tıklama metni seçer.
144
159
145
-
If we want to handle click events ourselves, then the "extra" selection doesn't look good.
160
+
Bütün tıklama olaylarını kendimiz kontrole almak istiyorsak, "ekstra" olarak metin seçimi iyi olmayabilir.
146
161
147
-
For instance, a double-click on the text below selects it in addition to our handler:
162
+
Örneğin, aşağıdaki metne çift tıklamak, işleyicimize ek olarak bir tıkladıgımız kelimeyi seçer:
<bondblclick="alert('dblclick')">Bana çift tıkla</b>
151
166
```
152
167
153
-
There's a CSS way to stop the selection: the `user-select`property from[CSS UI Draft](https://www.w3.org/TR/css-ui-4/).
168
+
Seçimi durdurmanın bir CSS yolu vardır: `user-select`özelliğini buradan incelyebilirsiniz.[CSS UI Draft](https://www.w3.org/TR/css-ui-4/).
154
169
155
-
Most browsers support it with prefixes:
170
+
Çoğu tarayıcı bunu destekler:
156
171
157
172
```html autorun height=50
158
173
<style>
@@ -164,80 +179,79 @@ Most browsers support it with prefixes:
164
179
}
165
180
</style>
166
181
167
-
Before...
182
+
Önce...
168
183
<bondblclick="alert('Test')">
169
-
Unselectable
184
+
Seçilemez
170
185
</b>
171
-
...After
186
+
...Sonra
172
187
```
173
188
174
-
Now if you double-click on "Unselectable", it doesn't get selected. Seems to work.
189
+
Şimdi "Seçilemez" üzerine çift tıklarsanız, seçilmez. Çalışıyor gibi görünüyor.
175
190
176
-
...But there is a potential problem! The text became truly unselectable. Even if a user starts the selection from "Before" and ends with "After", the selection skips "Unselectable" part. Do we really want to make our text unselectable?
191
+
...Ancak potansiyel bir sorun var! Metin gerçekten seçilemez hale geldi. Kullanıcı seçimi "Önce" den başlatıp "Sonra" ile bitirse bile, seçim "Seçilemeyen" kısmı atlar. Metnimizi gerçekten seçilemez hale getirmek istiyor muyuz?
177
192
178
-
Most of time, we don't. A user may have valid reasons to select the text, for copying or other needs. That may be inconvenient if we don't allow them to do it. So this solution is not that good.
193
+
Çoğu zaman bunu istemeyiz. Bir kullanıcının metni seçmek, kopyalamak veya diğer ihtiyaçları için geçerli nedenleri olabilir. Bunu yapmalarına izin vermezsek bu rahatsız edici olabilir. Yani bu çözüm o kadar iyi değil.
179
194
180
-
What we want is to prevent the selection on double-click, that's it.
195
+
İstediğimiz sadece çift tıklamayla seçimi engellemek, hepsi bu.
181
196
182
-
A text selection is the default browser action on `mousedown`event. So the alternative solution would be to handle `mousedown`and prevent it, like this:
197
+
Metin seçimi `mousedown`olayıyla beraber gerçekleşen bir tarayıcı işlemi. Bu yüzden alternatif yöntem `mousedown`olayını engellemek, şu şekilde:
Now the bold element is not selected on double clicks.
207
+
Artık kalın yazı tipiyle yazılmış öğe çift tıklamayla seçilmiyor.
193
208
194
-
The text inside it is still selectable. However, the selection should start not on the text itself, but before or after it. Usually that's fine though.
209
+
İçindeki metin hala seçilebilir. Ancak, seçim metnin kendisinde değil, ondan önce veya sonra başlamalıdır. Yine de genellikle bu sorun olmaz ve en iyi çözüm alternatifidir.
195
210
196
-
````smart header="Canceling the selection"
197
-
Instead of *preventing* the selection, we can cancel it "post-factum" in the event handler.
198
211
199
-
Here's how:
212
+
````smart header="Metin seçimini iptal etme"
213
+
Seçimi *önlemek* yerine, olay işleyicisini "post-factum" iptal edebiliriz.
-`key:Ctrl` ile işlem yapacaksanız, Mac kullanıcılarını unutmayın, Mac kullanıcıları`key:Cmd` kullanırlar bu sebeple `if (e.metaKey || e.ctrlKey)` ile bunu kontrol etmeniz gerekir.
234
248
235
-
-Window-relative coordinates: `clientX/clientY`.
236
-
-Document-relative coordinates: `pageX/pageY`.
249
+
-Pencereye bağlı koordinatlar : `clientX/clientY`.
250
+
-Belgeye bağlı koordinatlar : `pageX/pageY`.
237
251
238
-
It's also important to deal with text selection as an unwanted side-effect of clicks.
252
+
Ayrıca, tıklamaların istenmeyen bir yan etkisi olarak metin seçimiyle uğraşmak da önemlidir.
0 commit comments