Commit f554109f authored by 神楽坂玲奈's avatar 神楽坂玲奈

Input临时

parent 9654c7e6
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
#============================================================================== #==============================================================================
class Scene_Title < Scene class Scene_Title < Scene
require_relative 'window_title' require_relative 'window_title'
require_relative 'widget_inputbox'
def start def start
title = Dir.glob("graphics/titles/title_*.*") title = Dir.glob("graphics/titles/title_*.*")
title = title[rand(title.size)] title = title[rand(title.size)]
@background = Surface.load(title) @background = Surface.load(title)
...@@ -33,11 +35,17 @@ class Scene_Title < Scene ...@@ -33,11 +35,17 @@ class Scene_Title < Scene
@command_window.index = nil @command_window.index = nil
end end
when Event::MouseButtonDown when Event::MouseButtonDown
case event.button case event.button
when Mouse::BUTTON_LEFT when Mouse::BUTTON_LEFT
Widget_InputBox.show(0,0){|text, finished|p text, finished}
if @command_window.include?(event.x, event.y) if @command_window.include?(event.x, event.y)
@command_window.click((event.y - @command_window.y) / @command_window.class::Button_Height) @command_window.click((event.y - @command_window.y) / @command_window.class::Button_Height)
end end
when Mouse::BUTTON_RIGHT
Widget_InputBox.right
when 4 #scrool_up when 4 #scrool_up
@command_window.index = @index ? (@index-1) % Buttons.size : 0 @command_window.index = @index ? (@index-1) % Buttons.size : 0
when 5 when 5
......
class Widget_InputBox
require 'tk'
@@root=TkRoot.new {
withdraw
overrideredirect true
attributes :topmost, true
}
@@entry = TkEntry.new(@@root){
takefocus 1
validate :focusout
validatecommand{@@root.withdraw;@@proc.call(get, false);true}
bind('Key-Return'){@@root.withdraw;@@proc.call(get, true);true}
pack
}
def self.show(x,y,text=nil, &proc)
@@root.geometry "+#{x+TkWinfo.pointerx(@@root)-Mouse.state[0]}+#{y+TkWinfo.pointery(@@root)-Mouse.state[1]}"
@@root.deiconify
@@entry.text text if text
@@proc = proc
@@entry.focus :force
end
Thread.new{Tk.mainloop}
end
...@@ -57,4 +57,4 @@ class Window_Action < Window_List ...@@ -57,4 +57,4 @@ class Window_Action < Window_List
end end
def lostfocus def lostfocus
end end
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment