mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-12-21 20:29:17 +00:00
Allow double-clicking on disks in the list to mount them.
This commit is contained in:
parent
b24c43f97b
commit
567c60040e
@ -10,6 +10,7 @@
|
|||||||
#include <desk.h>
|
#include <desk.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <lineedit.h>
|
#include <lineedit.h>
|
||||||
|
#include <list.h>
|
||||||
#include <quickdraw.h>
|
#include <quickdraw.h>
|
||||||
#include <window.h>
|
#include <window.h>
|
||||||
|
|
||||||
@ -23,13 +24,15 @@
|
|||||||
#include "disksearch.h"
|
#include "disksearch.h"
|
||||||
#include "diskmount.h"
|
#include "diskmount.h"
|
||||||
|
|
||||||
|
/* Task record used for TaskMasterDA */
|
||||||
|
static WmTaskRec taskRec;
|
||||||
|
|
||||||
static void HandleEvent(int eventCode, WmTaskRec *taskRec);
|
static void HandleEvent(int eventCode, WmTaskRec *taskRec);
|
||||||
static boolean DoLEEdit (int editAction);
|
static boolean DoLEEdit (int editAction);
|
||||||
|
|
||||||
/* NDA-style action routine for our window */
|
/* NDA-style action routine for our window */
|
||||||
#pragma databank 1
|
#pragma databank 1
|
||||||
static int ActionProc(EventRecord *eventRec, int actionCode) {
|
static int ActionProc(EventRecord *eventRec, int actionCode) {
|
||||||
static WmTaskRec taskRec;
|
|
||||||
int handledAction = 0;
|
int handledAction = 0;
|
||||||
|
|
||||||
if (!windowOpened)
|
if (!windowOpened)
|
||||||
@ -41,7 +44,6 @@ static int ActionProc(EventRecord *eventRec, int actionCode) {
|
|||||||
switch (actionCode) {
|
switch (actionCode) {
|
||||||
case eventAction:
|
case eventAction:
|
||||||
/* Copy basic event rec & use our own wmTaskMask, as per IIgs TN 84 */
|
/* Copy basic event rec & use our own wmTaskMask, as per IIgs TN 84 */
|
||||||
memset(&taskRec, sizeof(taskRec), 0);
|
|
||||||
memmove(&taskRec, eventRec, 16);
|
memmove(&taskRec, eventRec, 16);
|
||||||
taskRec.wmTaskMask = 0x1F7FFF; /* everything except tmInfo */
|
taskRec.wmTaskMask = 0x1F7FFF; /* everything except tmInfo */
|
||||||
|
|
||||||
@ -76,6 +78,8 @@ asm void actionProcWrapper(void) {
|
|||||||
|
|
||||||
/* Handle an event after TaskMasterDA processing */
|
/* Handle an event after TaskMasterDA processing */
|
||||||
static void HandleEvent(int eventCode, WmTaskRec *taskRec) {
|
static void HandleEvent(int eventCode, WmTaskRec *taskRec) {
|
||||||
|
static unsigned int lastSelection;
|
||||||
|
|
||||||
switch (eventCode) {
|
switch (eventCode) {
|
||||||
case wInControl:
|
case wInControl:
|
||||||
switch (taskRec->wmTaskData4) {
|
switch (taskRec->wmTaskData4) {
|
||||||
@ -93,6 +97,22 @@ static void HandleEvent(int eventCode, WmTaskRec *taskRec) {
|
|||||||
case mountDiskButton:
|
case mountDiskButton:
|
||||||
DoMount();
|
DoMount();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case disksList:
|
||||||
|
if (taskRec->what == mouseDownEvt) {
|
||||||
|
if (taskRec->wmClickCount == 2) {
|
||||||
|
SubPt(&taskRec->wmLastClickPt, &taskRec->where);
|
||||||
|
if (taskRec->where.h >= -5 && taskRec->where.h <= 5 &&
|
||||||
|
taskRec->where.v >= -3 && taskRec->where.v <= 3 &&
|
||||||
|
NextMember2(0, (Handle)disksListHandle) == lastSelection)
|
||||||
|
{
|
||||||
|
DoMount();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastSelection = NextMember2(0, (Handle)disksListHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -144,3 +164,8 @@ static boolean DoLEEdit (int editAction) {
|
|||||||
};
|
};
|
||||||
return (id == searchLine);
|
return (id == searchLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitEventState(void) {
|
||||||
|
memset(&taskRec, sizeof(taskRec), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
#define BROWSEREVENTS_H
|
#define BROWSEREVENTS_H
|
||||||
|
|
||||||
asm void actionProcWrapper(void);
|
asm void actionProcWrapper(void);
|
||||||
|
void InitEventState(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,6 +109,8 @@ void ShowBrowserWindow(void) {
|
|||||||
|
|
||||||
wantToOpenWindow = 0;
|
wantToOpenWindow = 0;
|
||||||
|
|
||||||
|
InitEventState();
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (resourceFileOpened && !windowOpened) {
|
if (resourceFileOpened && !windowOpened) {
|
||||||
CloseResourceFile(resourceFileID);
|
CloseResourceFile(resourceFileID);
|
||||||
|
Loading…
Reference in New Issue
Block a user