This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:hotkey [2019/01/08 10:03] admin created |
tutorial:hotkey [2019/01/28 10:22] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
======Useful Hot-Keys====== | ======Useful Hot-Keys====== | ||
- | Hot-keys ที่สำคัญที่ผมจะแนะนำมีดังนี้ครับ | + | Hot-keys ที่สำคัญที่ผมจะแนะนำมีดังนี้ครับ \\ |
+ | |||
+ | ---- | ||
=====Ctrl + Shift + C===== | =====Ctrl + Shift + C===== | ||
- | ใช้สำหรับการเขียนโค๊ดใน Source Editor โดยเมื่อกดสามปุ่มดังนี้แล้ว จะเป็นการสร้าง implementation ของ Procedure/Function อย่างรวดเร็ว ไม่ต้องเสียเวลามาพิมพ์โค๊ดในส่วนนี้เอง | + | Hot-key ตัวนี้จะใช้ระหว่างการเขียนโค๊ดใน Source Editor โดยเมื่อกดสามปุ่มดังนี้แล้ว จะเป็นการสร้าง implementation ของ Procedure/Function อย่างรวดเร็ว ไม่ต้องเสียเวลามาพิมพ์โค๊ดในส่วนนี้เอง วิธีใช้สรุปได้ตามนี้ |
- | __**วิธีใช้**__ ต้อง | + | |
^ Steps ^ Source Editor ^ | ^ Steps ^ Source Editor ^ | ||
- | |1. สร้างโค๊ดในส่วนของ Declaration ให้เสร็จ|<sxh delphi;> | + | |1. สร้างโค๊ดในส่วนของ Declaration ให้เสร็จ \\ \\ (ตัวอย่างนี้ จะเป็นการสร้าง class ขึ้นมา โดยมี Method 2 ตัว คือ Procedure DoSomething กับ Function GetSomething) \\ \\ เลื่อน text curser มาไว้ที่ตำแหน่งไหนก็แต่ขอให้อยู่ภายในบรรทัด ของส่วนประกาศของ TMyClass (สามารถวางได้ภายในบรรทัด 3-8 แต่ขอแนะนำให้วางแถวสุดท้าย ในบรรทัดที่ 8 หลัง end;)|<sxh delphi;highlight: [6-7]> |
- | program Project1; | + | PROGRAM Project1; |
- | type | + | TYPE |
TMyClass = class(TPersistent) | TMyClass = class(TPersistent) | ||
FName:string; | FName:string; | ||
Line 16: | Line 17: | ||
function GetSomeThing:integer; | function GetSomeThing:integer; | ||
end; | end; | ||
- | begin | + | BEGIN |
- | end. | + | END. |
</sxh> | | </sxh> | | ||
- | |2. เลื่อน text curser มาไว้ที่ตำแหน่งไหนก็แต่ขอให้อยู่ภายในบรรทัด ของส่วนประกาศของ TMyClass (แนะนำให้วางแถวสุดท้าย ในบรรทัดที่ 8 หลัง end;) โค๊ดในส่วน implementation ของ method ของ TMyclass จะถูกสร้างขึ้นมาทันที|<sxh delphi;> | + | |2. จากนั้นกดปุ่ม Ctrl+Shift+C พร้อมกัน \\ \\ โค๊ดในส่วน method implementation ของ TMyclass จะถูกสร้างขึ้นมาทันที|<sxh delphi;highlight: [15-18,20-23]> |
- | program Project1; | + | PROGRAM Project1; |
- | + | TYPE | |
- | type | + | |
{ TMyClass } | { TMyClass } | ||
Line 45: | Line 45: | ||
end; | end; | ||
- | begin | + | BEGIN |
+ | END. | ||
+ | </sxh> | | ||
+ | |||
+ | \\ | ||
+ | นอกจากการใช้ Ctrl+SHift+C กับ Class/Object Methods แล้ว ยังสามารถใช้กับ Procedure/Function ทั่วไป ใน Unit ได้เช่นกัน ดังตัวอย่างต่อไปนี้ | ||
+ | |||
+ | <hidden> | ||
+ | ^ Steps ^ Source Editor ^ | ||
+ | |1. สร้างโค๊ดในส่วนของ Declaration ให้เสร็จ|<sxh delphi;highlight: [10-11]> | ||
+ | unit Unit1; | ||
+ | |||
+ | {$mode objfpc}{$H+} | ||
+ | |||
+ | interface | ||
+ | |||
+ | uses | ||
+ | Classes, SysUtils; | ||
+ | |||
+ | procedure DoSomething; | ||
+ | function GetSomething:integer; | ||
+ | |||
+ | implementation | ||
end. | end. | ||
</sxh> | | </sxh> | | ||
+ | |2. เลื่อน text curser มาไว้ที่ตำแหน่งไหนก็แต่ขอให้อยู่ภายในบรรทัดที่ Methods เหล่านั้นอยู่ จากนั้นกดปุ่ม Ctrl+Shift+C พร้อมกัน |<sxh delphi;highlight: [15-18,20-23]> | ||
+ | unit Unit1; | ||
+ | |||
+ | {$mode objfpc}{$H+} | ||
+ | |||
+ | interface | ||
+ | |||
+ | uses | ||
+ | Classes, SysUtils; | ||
+ | |||
+ | procedure DoSomething; | ||
+ | function GetSomething:integer; | ||
+ | |||
+ | implementation | ||
+ | |||
+ | procedure DoSomething; | ||
+ | begin | ||
+ | |||
+ | end; | ||
+ | |||
+ | function GetSomething: integer; | ||
+ | begin | ||
+ | |||
+ | end; | ||
+ | |||
+ | end. | ||
+ | </sxh> | | ||
+ | |||
+ | </hidden> | ||
+ | __**หมายเหตุ**__ - สามารถใช้ได้กับ Getter/Setter ของ Property ที่อยู่ในรูปของ Procedure/Function ได้เช่นกัน |