Knowledge

Event-driven programming

Source đź“ť

235: 198:
In addition to writing the event handlers, event handlers also need to be bound to events so that the correct function is called when the event takes place. For UI events, many IDEs combine the two steps: double-click on a button, and the editor creates an (empty) event handler associated with the
194:
While keeping track of history is normally trivial in a sequential program. Because event handlers execute in response to external events, correctly structuring the handlers to work when called in any order can require special attention and planning in an event-driven program.
438:
The JavaFX scene graph, which represents the graphical user interface of a JavaFX application, is not thread-safe and can only be accessed and modified from the UI thread also known as the JavaFX Application
152:
of retrieving/dispatching of events are common amongst applications, many programming frameworks take care of their implementation and expect the user to provide only the code for the event handlers.
179:
The actual logic is contained in event-handler routines. These routines handle the events to which the main program will respond. For example, a single left-button mouse-click on a command button in a
691: 1438: 597: 661: 559: 610: 760: 695: 1431: 590: 493: 824: 1424: 1174: 1036: 512: 1531: 1521: 1180: 502: 1579: 1536: 1526: 1516: 583: 1493: 1365: 1113: 833: 188: 127: 536: 379: 208: 450: 1508: 1205: 885: 829: 519:
Schiffer, S.; Frohlich, J.H. (1994). "Concepts and architecture of Vista-a multiparadigm programming environment".
337: 1488: 1065: 938: 869: 804: 727: 270: 90: 1597: 1568: 1483: 1243: 1006: 636: 245: 163:, whose 1960s design concept was similar to event-driven programming discussed above, provided a built-in main 101: 1498: 1021: 1011: 789: 321: 296: 191:
provide the programmer with GUI event templates, allowing the programmer to focus on writing the event code.
1405: 1385: 1315: 1258: 1220: 1210: 1170: 1095: 1031: 1001: 928: 917: 814: 794: 769: 732: 553: 1602: 1360: 1123: 1090: 985: 961: 923: 903: 799: 708: 686: 671: 311: 131: 1557: 1307: 1293: 1200: 1160: 1085: 991: 971: 838: 717: 651: 1400: 1165: 1075: 1055: 1041: 285: 68: 167:
loop (known as the "program cycle") where the calculations responded in accordance to 'indicators' (
1340: 1283: 1215: 953: 784: 212: 180: 79: 1390: 1370: 1311: 1298: 1278: 1105: 842: 746: 704: 575: 370:
Chandrasekaran, Premanand; Krishnan, Karthik; Ford, Neal; Byars, Brandon; Buijze, Allard (2022).
290: 1350: 1325: 1319: 1263: 1225: 913: 908: 860: 755: 656: 628: 619: 119: 421: 1252: 1248: 1190: 1142: 712: 487: 343: 1476: 1447: 1395: 1375: 1335: 1137: 996: 865: 852: 606: 316: 306: 275: 97: 28: 20: 8: 1330: 1268: 1080: 1060: 1046: 778: 646: 641: 1147: 1100: 1070: 1016: 875: 774: 666: 542: 331: 112: 1471: 1466: 1303: 1195: 1050: 1026: 966: 933: 895: 880: 819: 532: 375: 349: 108: 63:
inputs are common cases. Events may also be programmatically generated, such as from
48: 36: 546: 199:
user clicking the button and opens a text window so you can edit the event handler.
130:) are decoupled from their consumers. Whereas queue / message driven services (e.g. 1185: 1117: 981: 722: 524: 499: 168: 72: 1416: 1235: 1109: 975: 676: 506: 326: 211:. The Java AWT framework processes all UI changes on a single thread, called the 64: 1287: 943: 809: 570: 44: 40: 1591: 1273: 207:
Most existing GUI architectures use event-driven programming. Windows has an
123: 567:, an open-source example which is in production on MSN.com and Microsoft.com 466: 183:
program may trigger a routine that will open another window, save data to a
1461: 528: 481: 222:
Most network servers and frameworks such as Node.js are also event-driven.
56: 32: 1155: 475: 234: 280: 143: 86: 301: 149: 52: 396: 184: 605: 564: 156: 369: 216: 60: 352:, a distributed execution model for event-driven programming 78:
Event-driven programming is the dominant paradigm used in
476:
Event-Driven Programming: Introduction, Tutorial, History
164: 160: 107:
Although they do not exactly fit the event-driven model,
100:, although the task is easier in languages that provide 470: 372:
Domain-Driven Design with Java - A Practitioner's Guide
521:
Proceedings of 1994 IEEE Symposium on Visual Languages
513:
Event Driven Programming using Template Specialization
85:
In an event-driven application, there is generally an
225: 1446: 346:(an alternative architecture for computer systems) 215:. Similarly, all UI updates in the Java framework 1589: 518: 1432: 591: 96:Event-driven programs can be written in any 89:that listens for events and then triggers a 1439: 1425: 598: 584: 565:Distributed Publish/Subscribe Event System 419: 662:Programming in the large and in the small 219:occur on the JavaFX Application Thread. 118:It's important to differentiate between 171:) that were set earlier in the cycle. 126:paradigms: Event-driven services (e.g. 1590: 93:when one of those events is detected. 1420: 579: 394: 159:, an early programming language from 388: 229: 134:) are coupled with their consumers. 554:Event-Driven Programming and Agents 451:Event-Driven Programming in Node.js 13: 500:The event-driven programming style 82:applications and network servers. 14: 1614: 467:Concurrency patterns presentation 460: 174: 124:message-driven (aka queue driven) 1206:Partitioned global address space 515:, article by Christopher Diggins 338:Staged event-driven architecture 233: 226:Interrupt and exception handling 420:Fedortsova, Irina (June 2012). 271:Autonomous peripheral operation 1448:Types of programming languages 444: 413: 363: 202: 187:or exit the application. Many 1: 1548: 395:Samek, Miro (April 1, 2013). 356: 297:Hardware description language 137: 16:Computer programming paradigm 1580:Programming paradigms navbox 733:Uniform Function Call Syntax 65:messages from other programs 7: 1201:Parallel programming models 1175:Concurrent constraint logic 509:, article by Chris McDonald 496:, article by Jonathan Simon 312:Message-oriented middleware 264: 67:, notifications from other 10: 1621: 1294:Metalinguistic abstraction 1161:Automatic mutual exclusion 494:Rethinking Swing Threading 490:, article by Martin Fowler 478:, tutorial by Stephen Ferg 141: 35:is determined by external 1507: 1454: 1349: 1234: 1166:Choreographic programming 1136: 952: 894: 851: 754: 745: 685: 627: 618: 426:JavaFX Documentation Home 322:Publish–subscribe pattern 286:Event-driven architecture 80:graphical user interfaces 1216:Relativistic programming 560:LabWindows/CVI Resources 484:, tutorial by Alan Gauld 482:Event-Driven Programming 213:Event dispatching thread 115:have many similarities. 25:event-driven programming 422:"Concurrency in JavaFX" 291:Event stream processing 102:high-level abstractions 1226:Structured concurrency 611:Comparison by language 529:10.1109/VL.1994.363642 242:This section is empty. 1598:Programming paradigms 1569:Programming languages 1191:Multitier programming 1007:Interface description 607:Programming paradigms 571:Javascript Event loop 397:"Who Moved My State?" 344:Time-triggered system 374:. Packt Publishing. 317:Programming paradigm 307:Inversion of control 276:Dataflow programming 98:programming language 29:programming paradigm 21:computer programming 1331:Self-modifying code 939:Probabilistic logic 870:Functional reactive 825:Expression-oriented 779:Partial application 488:Event Collaboration 334:(a similar concept) 293:(a similar concept) 33:flow of the program 1603:Events (computing) 1244:Attribute-oriented 1017:List comprehension 962:Algebraic modeling 775:Anonymous function 667:Design by contract 637:Jackson structures 523:. pp. 40–47. 505:2005-02-20 at the 332:Signal programming 113:exception handling 109:interrupt handling 1558:Computer language 1545: 1544: 1414: 1413: 1304:Program synthesis 1196:Organic computing 1132: 1131: 1037:Non-English-based 1012:Language-oriented 790:Purely functional 741: 740: 350:Virtual synchrony 262: 261: 91:callback function 1610: 1584: 1578: 1573: 1567: 1562: 1556: 1441: 1434: 1427: 1418: 1417: 1316:by demonstration 1221:Service-oriented 1211:Process-oriented 1186:Macroprogramming 1171:Concurrent logic 1042:Page description 1032:Natural language 1002:Grammar-oriented 929:Nondeterministic 918:Constraint logic 820:Point-free style 815:Functional logic 752: 751: 723:Immutable object 642:Block-structured 625: 624: 600: 593: 586: 577: 576: 550: 454: 448: 442: 441: 435: 433: 417: 411: 410: 408: 407: 392: 386: 385: 367: 257: 254: 244:You can help by 237: 230: 1620: 1619: 1613: 1612: 1611: 1609: 1608: 1607: 1588: 1587: 1582: 1576: 1571: 1565: 1560: 1554: 1551: 1546: 1541: 1503: 1494:Very high-level 1450: 1445: 1415: 1410: 1352: 1345: 1236:Metaprogramming 1230: 1146: 1141: 1128: 1110:Graph rewriting 948: 924:Inductive logic 904:Abductive logic 890: 847: 810:Dependent types 758: 737: 709:Prototype-based 689: 687:Object-oriented 681: 677:Nested function 672:Invariant-based 614: 604: 539: 507:Wayback Machine 463: 458: 457: 449: 445: 431: 429: 418: 414: 405: 403: 393: 389: 382: 368: 364: 359: 327:Reactor pattern 267: 258: 252: 249: 228: 205: 177: 146: 140: 59:, and external 17: 12: 11: 5: 1618: 1617: 1606: 1605: 1600: 1586: 1585: 1574: 1563: 1550: 1547: 1543: 1542: 1540: 1539: 1534: 1529: 1524: 1519: 1513: 1511: 1505: 1504: 1502: 1501: 1496: 1491: 1486: 1480: 1479: 1474: 1469: 1464: 1458: 1456: 1452: 1451: 1444: 1443: 1436: 1429: 1421: 1412: 1411: 1409: 1408: 1403: 1398: 1393: 1388: 1383: 1378: 1373: 1368: 1363: 1357: 1355: 1347: 1346: 1344: 1343: 1338: 1333: 1328: 1323: 1301: 1296: 1291: 1281: 1276: 1271: 1266: 1261: 1256: 1246: 1240: 1238: 1232: 1231: 1229: 1228: 1223: 1218: 1213: 1208: 1203: 1198: 1193: 1188: 1183: 1178: 1168: 1163: 1158: 1152: 1150: 1134: 1133: 1130: 1129: 1127: 1126: 1121: 1106:Transformation 1103: 1098: 1093: 1088: 1083: 1078: 1073: 1068: 1063: 1058: 1053: 1044: 1039: 1034: 1029: 1024: 1019: 1014: 1009: 1004: 999: 994: 992:Differentiable 989: 979: 972:Automata-based 969: 964: 958: 956: 950: 949: 947: 946: 941: 936: 931: 926: 921: 911: 906: 900: 898: 892: 891: 889: 888: 883: 878: 873: 863: 857: 855: 849: 848: 846: 845: 839:Function-level 836: 827: 822: 817: 812: 807: 802: 797: 792: 787: 782: 772: 766: 764: 749: 743: 742: 739: 738: 736: 735: 730: 725: 720: 715: 701: 699: 683: 682: 680: 679: 674: 669: 664: 659: 654: 652:Non-structured 649: 644: 639: 633: 631: 622: 616: 615: 603: 602: 595: 588: 580: 574: 573: 568: 562: 557: 551: 537: 516: 510: 497: 491: 485: 479: 473: 462: 461:External links 459: 456: 455: 443: 412: 387: 380: 361: 360: 358: 355: 354: 353: 347: 341: 335: 329: 324: 319: 314: 309: 304: 299: 294: 288: 283: 278: 273: 266: 263: 260: 259: 240: 238: 227: 224: 204: 201: 176: 175:Event handlers 173: 142:Main article: 139: 136: 15: 9: 6: 4: 3: 2: 1616: 1615: 1604: 1601: 1599: 1596: 1595: 1593: 1581: 1575: 1570: 1564: 1559: 1553: 1552: 1538: 1535: 1533: 1530: 1528: 1525: 1523: 1520: 1518: 1515: 1514: 1512: 1510: 1506: 1500: 1497: 1495: 1492: 1490: 1487: 1485: 1482: 1481: 1478: 1475: 1473: 1470: 1468: 1465: 1463: 1460: 1459: 1457: 1453: 1449: 1442: 1437: 1435: 1430: 1428: 1423: 1422: 1419: 1407: 1404: 1402: 1399: 1397: 1394: 1392: 1389: 1387: 1384: 1382: 1379: 1377: 1376:Data-oriented 1374: 1372: 1369: 1367: 1364: 1362: 1359: 1358: 1356: 1354: 1348: 1342: 1339: 1337: 1334: 1332: 1329: 1327: 1324: 1321: 1317: 1313: 1309: 1305: 1302: 1300: 1297: 1295: 1292: 1289: 1285: 1282: 1280: 1277: 1275: 1274:Homoiconicity 1272: 1270: 1267: 1265: 1262: 1260: 1257: 1254: 1250: 1247: 1245: 1242: 1241: 1239: 1237: 1233: 1227: 1224: 1222: 1219: 1217: 1214: 1212: 1209: 1207: 1204: 1202: 1199: 1197: 1194: 1192: 1189: 1187: 1184: 1182: 1181:Concurrent OO 1179: 1176: 1172: 1169: 1167: 1164: 1162: 1159: 1157: 1154: 1153: 1151: 1149: 1144: 1139: 1135: 1125: 1122: 1119: 1115: 1111: 1107: 1104: 1102: 1099: 1097: 1094: 1092: 1089: 1087: 1084: 1082: 1079: 1077: 1076:Set-theoretic 1074: 1072: 1069: 1067: 1064: 1062: 1059: 1057: 1056:Probabilistic 1054: 1052: 1048: 1045: 1043: 1040: 1038: 1035: 1033: 1030: 1028: 1025: 1023: 1020: 1018: 1015: 1013: 1010: 1008: 1005: 1003: 1000: 998: 995: 993: 990: 987: 983: 980: 977: 973: 970: 968: 965: 963: 960: 959: 957: 955: 951: 945: 942: 940: 937: 935: 932: 930: 927: 925: 922: 919: 915: 912: 910: 907: 905: 902: 901: 899: 897: 893: 887: 884: 882: 879: 877: 874: 871: 867: 864: 862: 859: 858: 856: 854: 850: 844: 840: 837: 835: 834:Concatenative 831: 828: 826: 823: 821: 818: 816: 813: 811: 808: 806: 803: 801: 798: 796: 793: 791: 788: 786: 783: 780: 776: 773: 771: 768: 767: 765: 762: 757: 753: 750: 748: 744: 734: 731: 729: 726: 724: 721: 719: 716: 714: 710: 706: 703: 702: 700: 697: 693: 688: 684: 678: 675: 673: 670: 668: 665: 663: 660: 658: 655: 653: 650: 648: 645: 643: 640: 638: 635: 634: 632: 630: 626: 623: 621: 617: 612: 608: 601: 596: 594: 589: 587: 582: 581: 578: 572: 569: 566: 563: 561: 558: 555: 552: 548: 544: 540: 538:0-8186-6660-9 534: 530: 526: 522: 517: 514: 511: 508: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 472: 468: 465: 464: 452: 447: 440: 427: 423: 416: 402: 398: 391: 383: 381:9781800564763 377: 373: 366: 362: 351: 348: 345: 342: 339: 336: 333: 330: 328: 325: 323: 320: 318: 315: 313: 310: 308: 305: 303: 300: 298: 295: 292: 289: 287: 284: 282: 279: 277: 274: 272: 269: 268: 256: 247: 243: 239: 236: 232: 231: 223: 220: 218: 214: 210: 200: 196: 192: 190: 186: 182: 172: 170: 166: 162: 158: 154: 151: 145: 135: 133: 129: 125: 121: 116: 114: 110: 105: 103: 99: 94: 92: 88: 83: 81: 76: 74: 70: 66: 62: 58: 54: 50: 46: 42: 38: 34: 31:in which the 30: 26: 22: 1583:}} 1577:{{ 1572:}} 1566:{{ 1561:}} 1555:{{ 1381:Event-driven 1380: 785:Higher-order 713:Object-based 520: 446: 437: 430:. Retrieved 425: 415: 404:. Retrieved 400: 390: 371: 365: 250: 246:adding to it 241: 221: 206: 197: 193: 178: 155: 148:Because the 147: 120:event-driven 117: 106: 95: 84: 77: 57:touchscreens 43:events from 24: 18: 1477:Interpreted 1391:Intentional 1371:Data-driven 1353:of concerns 1312:Inferential 1299:Multi-stage 1279:Interactive 1156:Actor-based 1143:distributed 1086:Stack-based 886:Synchronous 843:Value-level 830:Applicative 747:Declarative 705:Class-based 203:Common uses 71:, or other 1592:Categories 1509:Generation 1489:High-level 1366:Components 1351:Separation 1326:Reflective 1320:by example 1264:Extensible 1138:Concurrent 1114:Production 1101:Templating 1081:Simulation 1066:Scientific 986:Spacecraft 914:Constraint 909:Answer set 861:Flow-based 761:comparison 756:Functional 728:Persistent 692:comparison 657:Procedural 629:Structured 620:Imperative 406:2018-01-28 401:Dr. Dobb's 357:References 281:DOM events 209:event loop 150:event loop 144:Event loop 138:Event loop 87:event loop 1484:Low-level 1253:Inductive 1249:Automatic 1071:Scripting 770:Recursive 556:, chapter 471:scaleconf 469:given at 432:4 January 302:Interrupt 53:touchpads 49:keyboards 1549:See also 1499:Esoteric 1472:Compiled 1467:Assembly 1406:Subjects 1396:Literate 1386:Features 1341:Template 1336:Symbolic 1308:Bayesian 1288:Hygienic 1148:parallel 1027:Modeling 1022:Low-code 997:End-user 934:Ontology 866:Reactive 853:Dataflow 547:15927869 503:Archived 428:. Oracle 265:See also 253:May 2024 185:database 75:events. 1462:Machine 1361:Aspects 1269:Generic 1259:Dynamic 1118:Pattern 1096:Tactile 1061:Quantum 1051:filters 982:Command 881:Streams 876:Signals 647:Modular 439:thread. 132:AWS SQS 128:AWS SNS 73:network 69:threads 1532:Fourth 1522:Second 1124:Visual 1091:System 976:Action 800:Strict 545:  535:  378:  340:(SEDA) 217:JavaFX 61:sensor 37:events 1537:Fifth 1527:Third 1517:First 1455:Level 1401:Roles 1284:Macro 1047:Pipes 967:Array 944:Query 896:Logic 805:GADTs 795:Total 718:Agent 543:S2CID 169:flags 27:is a 1049:and 696:list 533:ISBN 434:2018 376:ISBN 189:IDEs 122:and 111:and 55:and 45:mice 954:DSL 525:doi 248:. 181:GUI 165:I/O 161:IBM 157:RPG 19:In 1594:: 1318:, 1314:, 1310:, 1116:, 1112:, 841:, 832:, 711:, 707:, 694:, 541:. 531:. 436:. 424:. 399:. 104:. 51:, 47:, 41:UI 39:. 23:, 1440:e 1433:t 1426:v 1322:) 1306:( 1290:) 1286:( 1255:) 1251:( 1177:) 1173:( 1145:, 1140:, 1120:) 1108:( 988:) 984:( 978:) 974:( 920:) 916:( 872:) 868:( 781:) 777:( 763:) 759:( 698:) 690:( 613:) 609:( 599:e 592:t 585:v 549:. 527:: 453:. 409:. 384:. 255:) 251:(

Index

computer programming
programming paradigm
flow of the program
events
UI
mice
keyboards
touchpads
touchscreens
sensor
messages from other programs
threads
network
graphical user interfaces
event loop
callback function
programming language
high-level abstractions
interrupt handling
exception handling
event-driven
message-driven (aka queue driven)
AWS SNS
AWS SQS
Event loop
event loop
RPG
IBM
I/O
flags

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑